dilame / instagram-private-api

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

IgCheckpointError: POST /api/v1/accounts/login/ - 400 Bad Request; challenge_required #1223

Closed wanghaisheng closed 4 years ago

wanghaisheng commented 4 years ago
function doInstagramLogin() {
    return new Promise(function(resolve, reject) {
        // execute all requests prior to authorization in the real Android applicatio

        igClient.simulate.preLoginFlow().then(function() {
            console.log("Logging in to " + loginDetails.username + "...");
            igClient.account.login(loginDetails.username, loginDetails.password).then(function(loggedInUser) {
                // execute all requests after authorization in the real Android application
                // we're doing this on a next tick, as per the example given in instagram-private-api's tutorial...
                process.nextTick(async function() {
                    await igClient.simulate.postLoginFlow();
                });
                console.log("Login successful!");
                resolve(loggedInUser);
            })
            .catch(function(err) {
                console.warn("Failed to sign in!");
                console.error(err);
            });
        })
        .catch(function(err) {
            console.warn("Failed to simulate pre-login flow!");
            console.error(err);
        });
    });
}

Error and Output

IgCheckpointError: POST /api/v1/accounts/login/ - 400 Bad Request; challenge_required
    at Request.handleResponseError (/root/offloaddogsboner_insta_reddit_bot/node_modules/instagram-private-api/dist/core/request.js:107:24)
    at Request.send (/root/offloaddogsboner_insta_reddit_bot/node_modules/instagram-private-api/dist/core/request.js:53:28)
    at <anonymous>

how to adjust code will challenge gone?

i have change pass,remove a login activity before run my bot have tried this, though not famaliar with nodejs code.

function doInstagramLogincheckpoint() {
    return new Promise(function(resolve, reject) {
        // execute all requests prior to authorization in the real Android applicatio
(async () => {
  const ig = new IgApiClient();
  ig.state.generateDevice(loginDetails.userName + "_blahblahblah");
//  ig.state.proxyUrl = process.env.IG_PROXY;
  Bluebird.try(async () => {
    const auth = await ig.account.login(loginDetails.username, loginDetails.password);
    console.log(auth);
  }).catch(IgCheckpointError, async () => {
    console.log(ig.state.checkpoint); // Checkpoint info here
    await ig.challenge.auto(true); // Requesting sms-code or click "It was me" button
    console.log(ig.state.checkpoint); // Challenge info here
    const { code } = await inquirer.prompt([
      {
        type: 'input',
        name: 'code',
        message: 'Enter code',
      },
    ]);
    console.log(await ig.challenge.sendSecurityCode(code));
  }).catch(e => console.log('Could not resolve checkpoint:', e, e.stack));
})();

    });
}
Nerixyz commented 4 years ago

There are several issues on this topic.

wanghaisheng commented 4 years ago

@ Nerixyz read and none of them works though

Nerixyz commented 4 years ago

@ Nerixyz read and none of them works though

Then comment on these issues instead of opening a new one.

rainb3rry commented 4 years ago

@wanghaisheng If you don't wan't get challenge response you should use same IP known by Instagram for the account.

AsifShaafi commented 3 years ago

@wanghaisheng If you don't wan't get challenge response you should use same IP known by Instagram for the account.

can you suggest how I can do it? As I'm facing the same issue.

wanghaisheng commented 3 years ago

@AsifShaafi try selenium fix proxy or ip is prefered use profile and cookies use undetected driver seleniumwire and selenium_stealth

AsifShaafi commented 3 years ago

@AsifShaafi try selenium fix proxy or ip is prefered use profile and cookies use undetected driver seleniumwire and selenium_stealth

@wanghaisheng Thanks for the reply. I haven't worked with selenium before, so I'm unaware of it. But I'll definitely look into that. Just one more thing, if you can help, I'm basically using this API for my backend server. So the user has no activity with my service. Will this help my situation?

wanghaisheng commented 3 years ago

I have no luck with this lib at last

thian4 commented 2 years ago

@wanghaisheng what solution you have? use another lib?

TheNewAggregator commented 2 years ago

Hello everybody,

I'm having a lot of checkpoint problems lately.

If someone has a solution to this, please email me:

My gmail is danielpaixaodp2021@gmail.com

Did someon have this kind of problem and fix it?

rendi12345678 commented 8 months ago

how to solve it