dilame / instagram-private-api

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

NoChallengeRequired when trying to second time #631

Closed nirajmchauhan closed 5 years ago

nirajmchauhan commented 5 years ago

Hello,

I have hit a weird issue. When I try to log in for the account A, it forces me to take the challenge, using Client.Web.Challenge I complete it via email step and then the login session is created. Now when I try for second time for account B, it again forces me to take the challenge, but when I try to resolve it shows me NoChallengeRequired. Now I am running my code on an express server, this only happens after the first challenge. In all the cases first challenge works well, unless I restart the node server.

For other tries I get following:

{ [NoChallengeRequired: No challenge is required to use account!]
  name: 'NoChallengeRequired',
  message: 'No challenge is required to use account!' }

My code:

const getSession = (username, password) => {
    const device = new Client.Device(username);
    const storage = new Client.CookieFileStorage(`${__dirname}/cookies/${username}.json`);
    return Client.Session.create(device, storage, username, password)
        .then((session) => {
            return session.getAccount()
                .then(() => {
                    return session;
                })
        })
        .catch((error) => {
        const errorName = _.get(error, 'name', 'NoError');
        const errorMessage = _.get(error, 'message');
        if (errorName === 'CheckpointError') {
            return Client.Web.Challenge.resolve(error, 'email')
                .then(challenge => {
                    let challengeId = Number(Math.round(Math.random() * 111111111)).toString(16);
                    challenges[challengeId] = challenge;
                    return {
                        status: "challenge",
                        type: challenge.type,
                        challengeId: challengeId,
                        url: error.url,
                    };
                })
        }
    });
};

I am using 0.7.0 version.

I tried to debug, but for the second Challenge resolve request and the response I am getting from instagram is

{"action": "close", "status": "ok"}

Instead of

{"step_name": "select_verify_method", "step_data": {"choice": "1", "fb_access_token": "None", "big_blue_token": "None", "google_oauth_token": "true", "email": "p****i@u*****.com"}, "user_id": 10483985904, "nonce_code": "S05gveXm3k", "status": "ok"}
dilame commented 5 years ago

Hi, @nirajmchauhan. First of all - try to install 0.7.1 version of library.

npm i git+https://github.com/dilame/instagram-private-api.git#v0.7.1

Second thing - yes, we have problems with checkpoints. One of the hardest thing is trigger checkpoint on demand to explore instagram's behaviour. If you have any recipies - please, share it with us :)

nirajmchauhan commented 5 years ago

I can definitely help on this but need to understand what is the issue. Why Instagram is denying this for the second time but when I restart the express server it works fine for the same request

usamawaleed commented 5 years ago

HI all,

I am a php guy and I am using mpg25 instagram private api, I am also facing same type of issue when we try login via our app we get a response "challenge required" but when I login on instagram via web or via phone there is no alert message that shows instagram raise a flag.

I have one other question is there a way to create a login session by using jQuery or javascrip purely without using any server like node.js or apache in my case

dilame commented 5 years ago

I can definitely help on this but need to understand what is the issue. Why Instagram is denying this for the second time but when I restart the express server it works fine for the same request

Are you sure the request is the same? Bit-to-bit?

usamawaleed commented 5 years ago

this is my test account you can try to login, now when I try to login into this account even from instagram.com or from mobile app using my local IP it is not allow me to login not showing any error or something like that I am sending you my account credentials on direct to your email account

nirajmchauhan commented 5 years ago

I can definitely help on this but need to understand what is the issue. Why Instagram is denying this for the second time but when I restart the express server it works fine for the same request

Are you sure the request is the same? Bit-to-bit?

Yes, it's exactly the same. For now, I implemented a hacky solution, whenever I hit that issue I just do process.exit() and then PM2 manages to restart it.

dilame commented 5 years ago

Yes, it's exactly the same. For now, I implemented a hacky solution, whenever I hit that issue I just do process.exit() and then PM2 manages to restart it.

I'm pretty sure that if you will actually compare your requests, you will see the difference between them 😄

usamawaleed commented 5 years ago

sir thank you for your reply , sir I am not Node.js guy so i am not able to properly understand your above message. it  will nice if you could provide me code what you did. Best Regards usama waleed  On Wednesday, January 23, 2019, 4:35:25 PM GMT+5, Дмитрий notifications@github.com wrote:

Yes, it's exactly the same. For now, I implemented a hacky solution, whenever I hit that issue I just do process.exit() and then PM2 manages to restart it.

I'm pretty sure that if you will actually compare your requests, you will see the difference between them 😄

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dish615 commented 5 years ago

upgrading versions solved the issue for me! thank you!

MeEgor commented 5 years ago

I had the similar issue with one account. It required challenge and when you try to resolve it, challenge just disappears. It was helpful to login with incorrect password and then login again with the correct one.

RVisal commented 5 years ago

HI all,

I am a php guy and I am using mpg25 instagram private api, I am also facing same type of issue when we try login via our app we get a response "challenge required" but when I login on instagram via web or via phone there is no alert message that shows instagram raise a flag.

Hi

Does {"action":" close"," status":" ok"} constantly return, or do you have another problem? Trying to solve this also for mpg25...

RVisal commented 5 years ago

Very very Important. A personal Request, The response I sent you is from some very important account so please don't use credentials for any type of testing I sent you this response just of read only Best regards usama waleed On Friday, February 1, 2019, 10:58:57 PM GMT+5, RVisal notifications@github.com wrote: HI all, I am a php guy and I am using mpg25 instagram private api, I am also facing same type of issue when we try login via our app we get a response "challenge required" but when I login on instagram via web or via phone there is no alert message that shows instagram raise a flag. Hi Does {"action ":" close "," status ":" ok "}" constantly return, or do you have another problem? Trying to solve this also for mpg25... — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Why did you put it in open access? Urgently change your login information.