dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

IgCookieNotFoundError: Cookie "ds_user_id" not found on login #997

Closed mcpengelly closed 4 years ago

mcpengelly commented 4 years ago

my user id is correct, my password is too. My code was working last week, suddenly stopped working. This is what happens when i try to send a challenge request, without sending a challenge request i get 400 error challenge required Any ideas whats going on here?

My code:

const sendIGChallengeRequest = async () => {
  await ig.challenge.auto(true); // Requesting sms-code or click "It was me" button
  console.log(ig.state.checkpoint);
  const { code } = await inquirer.prompt([
    {
      message: 'Enter code',
      name: 'code',
      type: 'input'
    }
  ]);
  await ig.challenge.sendSecurityCode(code);
};

const igLogin = async (): Promise<void> => {
  ig.state.generateDevice(process.env.IG_USERNAME);

  // login with credentials
  try {
    await ig.account.login(process.env.IG_USERNAME, process.env.ID_PASSWORD);
  } catch (err) {
      sendIGChallengeRequest();
  }
  // The same as preLoginFlow()
  // Optionally wrap it to process.nextTick so we dont need to wait ending of this bunch of requests
  process.nextTick(() => ig.simulate.postLoginFlow());
};

Error trace:

(node:75468) UnhandledPromiseRejectionWarning: IgCookieNotFoundError: Cookie "ds_user_id" not found
    at State.extractCookieValue (/Users/matthewpengelly/Documents/batcave/instagram-saved-downloader/node_modules/instagram-private-api/src/core/state.ts:151:13)
    at State.get cookieUserId [as cookieUserId] (/Users/matthewpengelly/Documents/batcave/instagram-saved-downloader/node_modules/instagram-private-api/src/core/state.ts:132:17)
    at SimulateService.facebookOta (/Users/matthewpengelly/Documents/batcave/instagram-saved-downloader/node_modules/instagram-private-api/src/services/simulate.service.ts:80:35)
    at /Users/matthewpengelly/Documents/batcave/instagram-saved-downloader/node_modules/instagram-private-api/src/services/simulate.service.ts:44:18
    at Bluebird.map.request (/Users/matthewpengelly/Documents/batcave/instagram-saved-downloader/node_modules/instagram-private-api/src/services/simulate.service.ts:60:45)
From previous event:
mcpengelly commented 4 years ago

on further investigation i think my account is just having issues in general....