dilame / instagram-private-api

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

checkPoint result.action == "close" #993

Closed LexSerest closed 4 years ago

LexSerest commented 4 years ago

Hello My account use 2fa authentication In checkPoint when sending code var result = await ig.challenge.sendSecurityCode (code) in response - {"action":"close","status":"ok"} And again comes sms And the logged_in_user field stays undefined.

In IgCheckpointError response.body

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

response in challenge.auto(true)

{
  "step_name": "verify_code",
  "step_data": {
    "security_code": "None",
    "sms_resend_delay": 60,
    "phone_number_preview": "1234",
    "resend_delay": 60,
    "contact_point": "1234",
    "form_type": "phone_number",
    "phone_number_formatted": "+40 *** ***-12-34",
    "phone_number": "+40 *** ***-12-34"
  },
  "user_id": 123456891011,
  "nonce_code": "JcLBOAsCHk",
  "status": "ok"
}

Who knows how to solve this problem?

LexSerest commented 4 years ago

solution:

(async () => {
  const ig = new IgApiClient();
  ig.state.generateDevice(process.env.IG_USERNAME)
  Bluebird.try(async () => {
    const auth = await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
  }).catch(IgCheckpointError, async () => {
    // why not use auto? he sends 3 messages
    await ig.challenge.selectVerifyMethod('0'); // use sms
    // verify code
    await ig.challenge.sendSecurityCode(code);

    // ...waiting for the second message from instagram...

    Bluebird.try(async () => {
      await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
    }).catch(IgLoginTwoFactorRequiredError, (e) => {
      const two_factor_identifier = e.response.body.two_factor_info.two_factor_identifier;
      const verificationCode = "<in second message>"
      await ig.account.twoFactorLogin(...);
    })

  });
})();