dilame / instagram-private-api

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

Question: How to correctly handle challenges? #362

Closed nvivo closed 7 years ago

nvivo commented 7 years ago

I'm trying this API and I'm getting a challenge for my account. While trying to handle it, I cannot make the methods to work. This is my code:

Client.Session.create(device, storage, 'myuser', 'mypass')
.catch(Client.Exceptions.CheckpointError, e => {
    Client.Web.Challenge.resolve(e);
});

and I get this in the console: Unhandled rejection RequestError: challenge_required

If I just catch the error with catch(e => ...) I see this:

{
    "name": "RequestError",
    "message": "challenge_required",
    "json": {
        "message": "challenge_required",
        "challenge": {
            "url": "https://i.instagram.com/challenge/0000000000/BsL0iMWjGz/",
            "api_path": "/challenge/0000000000/BsL0iMWjGz/",
            "hide_webview_header": true,
            "lock": true,
            "logout": false,
            "native_flow": true
        },
        "status": "fail",
        "error_type": "checkpoint_challenge_required"
    }
}

Am I doing something wrong or is this a bug?

MMrR0b0TT commented 7 years ago

+1

henriqueandradesilva commented 7 years ago

+1

henriqueandradesilva commented 7 years ago

@nvivo I'm having the same problem solved it? I'm from Brazil too.

IvanMMM commented 7 years ago

Trying to solve it. CheckpointError should be generated by lib itself. Can you pls tell me the StatusCode from server response? Or even the login/pass from your account so I could check it live

nvivo commented 7 years ago

@IvanMMM The server returns HTTP 400. Sorry, I cannot pass my password, but I tested with other 2 accounts and it's the same behavior.

The issue seems to be here.

As the json shows, the message now reads challenge_required. Probably a new message not being handled.

henriqueandradesilva commented 7 years ago

@nvivo, I realized the same thing here as I understood the instagram changed the return of the challenge, so we are not managing to handle the error

IvanMMM commented 7 years ago

@henriqueandradesilva it looks same for me. Are you sure about that? That's the cause if it's true. Or ig could change the response code

nvivo commented 7 years ago

@IvanMMM You're testing for checkpoint_required. It comes as "message": "challenge_required", for me now. Not sure if it' by country, but maybe you could test for both?

I changed it locally and it worked.

IvanMMM commented 7 years ago

@nvivo, didn't noticed it. You are right :) Will fix it now

nvivo commented 7 years ago

Thanks!

MMrR0b0TT commented 7 years ago

Sorry about reopening here, but are you all getting the same json result as repository code is parsing? I don't know why, but mine is very different.

IvanMMM commented 7 years ago

What's your response?

IvanMMM commented 7 years ago

Improvements made in #377

jblewdv commented 6 years ago

@IvanMMM I'm experiencing this issue as well. What did you guys do to resolve it? My server is in Virginia, but each session request is coming from all over the world for the software I'm writing. Curious how you fixed it?

pasevin commented 6 years ago

it took me a while to notice that the npm repo is not up to date with the latest github commits ;) just saying