dilame / instagram-private-api

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

No checkpoint data available #740

Closed avoqado closed 5 years ago

avoqado commented 5 years ago

What means body.action === 'close' in challenge.repository?

private middleware(body: ChallengeStateResponse) {
    if (body.action === 'close') {
      this.client.state.checkpoint = null;
      this.client.state.challenge = null;
    } else {
      this.client.state.challenge = body;
    }
  }

I have IgNoCheckpointError: No checkpoint data available in some accounts. But I don't understand and can't find how to fix this.

dilame commented 5 years ago

Show the code example to reproduce

avoqado commented 5 years ago

Standard login

await ig.simulate.preLoginFlow();
return ig.account.login(account.username, account.password);

Catch:

if (e instanceof IgCheckpointError) {
    await ig.challenge.auto(true); <--- exception here
    account.checkpoint = ig.state.checkpoint; //save in db to use in future
    account.appCookie = await ig.state.serializeCookieJar();
}

IgNoCheckpointError: No checkpoint data available at State.get challengeUrl [as challengeUrl] (/instagram-private-api/dist/core/state.js:73:19) at ChallengeRepository.state (/instagram-private-api/dist/repositories/challenge.repository.js:8:36) at ChallengeRepository.auto (/instagram-private-api/dist/repositories/challenge.repository.js:56:24)

On some accounts works good, but sometimes throws error. I'm not sure, but if you have only email it will work and if you have connected email and phone - doesnt'work.

UPD: Found issue with similar problem in mgp25 repo.

avoqado commented 5 years ago

Also sometimes get this error in preLoginFlow(): IgResponseError: POST /api/v1/qe/sync/ - 400 Bad Request; No ID given

dilame commented 5 years ago

You can imagine checkpoint as a wall, that won't let you into a beautiful instagram world. There is a text on this wall, that requires you to pass a chellenge with uniq id. So, in order to pass a challenge, you need the checkpoint first.

instagram-private-api centrally catches checkpoint errors and writes it into the state. But if you are trying to pass a challenge in fresh IgApiClient instance you will get IgNoCheckpointError, because there is no checkpoint in state. So you must ensure there is checkpoint in your state.

avoqado commented 5 years ago

it is the same state in login and in catch.

dilame commented 5 years ago

If so there may be 2 ways. 1) There is a bug in library 2) Something wrong with your account For me challenge.auto() is working. I don't have enough time now to debug what is going on, i hope community will help you here.

aadityatamrakar commented 5 years ago

@dilame I am having same issue, many accounts work fine. But in some account it gets stuck in checkpoint. I have rotating proxy.

When I try to login it give checkpoint but when I reset checkpoint it give no checkpoint error.

Please check.

aadityatamrakar commented 5 years ago

@dilame

This is the checkpoint data.

{ "message": "challenge_required", "challenge": { "url": "https://i.instagram.com/challenge/2351642412/KMQya0Xted/", "api_path": "/challenge/2351642412/KMQya0Xted/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true }, "status": "fail", "error_type": "checkpoint_challenge_required" }

When I do reset = true, then it gives no checkpoint data available error.

If i do reset = false, then it gives error in step_name undefined at /repositories/challenge.repository.js:59:27

Please check.

sshmyg commented 5 years ago

I can assume this bug happens when we have no choice, just field to enter the code. Like this

image