Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"login_required" error after few successful requests #1787

Open
5 of 6 tasks
jol-cochet-pro opened this issue Jun 15, 2024 · 1 comment
Open
5 of 6 tasks

"login_required" error after few successful requests #1787

jol-cochet-pro opened this issue Jun 15, 2024 · 1 comment
Labels
bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin

Comments

@jol-cochet-pro
Copy link

jol-cochet-pro commented Jun 15, 2024

Bug Report

Read the Notes and fill out the form.

Notes

Your issue will be closed if you violate any rule below.

  • You need to include a meaningful section of your code
    (not your entire project and not a single line).
  • Please do not add screenshots as they're not easy to work with.
  • Errors like IgActionSpamError (feedback_required), IgCheckpointError (challenge_required), checkpont_required, login_required
    are "common" and there are multiple issues, search here.
  • You can delete this section after reading it.

Form

Put an [x] if you meet the condition, else leave [ ].

Requirements

Platform

  • I'm using Node.js version v21.7.3
  • I'm using electron

Description

I have a problem with a "login_required" error that append randomly. I have a loop that search through my instagram users and then read their discovery feed. With that loop, I load a session that I have stored in my database using the this.state.deserialize function and then I check if I can retrieve my user info. When I retrieve my user info, it works the 3 first try and then it throw me a "login_required" error, even if I set my loop to run every 40 seconds. I know instagram could block my ip address and for that I use a residential proxy so i'm pretty sure it's not related.
Please help me.

Code

// This is my load function
async loadSession(userID: string): Promise<void> {
    const user = await this.prismaService.user.findUnique({
      where: { id: userID },
      select: userSelector,
    });

    if (!user) {
      throw new NotFoundException(
        `The user with id ${userID} does not exists.`,
      );
    }

    if (!user.instagramState) {
      throw new Error(`
        The user with id ${userID} does not have an instagram state.
      `);
    }

    this.state.proxyUrl =
      'http://customer-xxxxxxx-country-FR-region-Ain:[email protected]:30000';
    await this.state.deserialize(user.instagramState);
    await this.user.info(this.state.cookieUserId).catch(async (err) => {
      if (err.code && err.error.code !== 'ECONNRESET') {
        await this.prismaService.user.update({
          where: { id: userID },
          data: {
            lastInstaBlocked: new Date(),
          },
        });
      }
      throw err;
    });
  }
  
  // And this is my loop 
  for (const user of users) {
        const isBlockedFromInsta =
          user.lastInstaBlocked &&
          this.getDiffFromNow(user.lastInstaBlocked) < 24;

        const dontSearch =
          !user.isSearchActivated || !user.instagramState || isBlockedFromInsta;

        if (dontSearch) {
          this.logger.debug(
            `The user with id ${user.id} ${isBlockedFromInsta ? 'has been blocked by instagram' : 'has not activate searching'}.`,
          );
          continue;
        }

        try {
          await this.instagramService.loadSession(user.id);
        } catch (err) {
          this.logger.debug(err);
          this.logger.warn(
            `The user with id ${user.id} could not have been logged in instagram`,
          );
          continue;
        }

        try {
          const discoverFeed = this.instagramService.feed.topicalExplore();

          const discoverRequest = await discoverFeed.items();

          const discoverUsers = discoverRequest.flatMap((el) =>
            el.layout_content.medias?.map((el) => el.media.user),
          );

          // Adding users to the database
        } catch (err) {
          // Error handling
        }
      }

Error and Output

It's a typical "login_required" error that append when a user is not logged. 
@jol-cochet-pro jol-cochet-pro added bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin labels Jun 15, 2024
@sunmasters
Copy link

Check API, maybe some where in the code, session not passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unconfirmed This issue hasn't been read/confirmed/accepted by an admin
Projects
None yet
Development

No branches or pull requests

2 participants