dilame / instagram-private-api

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

IgResponseError: POST /api/v1/accounts/login/ - 400 Bad Request #820

Closed codingzombies closed 4 years ago

codingzombies commented 5 years ago

Right after login it IG returns the following response:

{ message: '', two_factor_required: true, two_factor_info: { username: 'lyxsus', sms_two_factor_on: true, totp_two_factor_on: false, obfuscated_phone_number: '3469', two_factor_identifier: 'WrLhM8Bsqb', show_messenger_code_option: false, show_new_login_screen: true, show_trusted_device_option: false, phone_verification_settings: { max_sms_count: 2, resend_sms_delay_sec: 60, robocall_count_down_time_sec: 30, robocall_after_max_sms: true } }, phone_verification_settings: { max_sms_count: 2, resend_sms_delay_sec: 60, robocall_count_down_time_sec: 30, robocall_after_max_sms: true }, status: 'fail' }

And I get SMS code notification right after that. Happens on multiple accounts, multiple proxies, VPN and nots. It works only when I get a code via email.

avoqado commented 5 years ago

turn off two-factor authentication

sshmyg commented 5 years ago

Is there any solution how to enter this code and add session to cache, that we no need to login every time?

Nerixyz commented 5 years ago

I'm working on a pr, where you can just set trustThisDevice to true

StarrHelixx commented 5 years ago

@Nerixyz, Im interested in getting 2FA to work... I saw your PR #835, but can't seem to get 2FA to work (or checkpoints at all: Error: No checkpoint data available). Can you provide an example for your implementation?

Nerixyz commented 5 years ago

await Bluebird.try(() => ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD)).catch(IgLoginTwoFactorRequiredError, (err) => {
    return ig.account.twoFactorLogin({
      twoFactorIdentifier: err.response.body.two_factor_info.two_factor_identifier,
      verificationMethod: '1',
      trustThisDevice: '1',
      username: process.env.IG_USERNAME,
      verificationCode: '000000',
    });
  });```
This should work
StarrHelixx commented 5 years ago

Yes! Tyvm, this works like a charm (and got checkpoints working too now)

This issue and #740 can probably be closed now.

iSeanWeiDev commented 4 years ago

No it doesn't work correctly!

iSeanWeiDev commented 4 years ago

image

Nerixyz commented 4 years ago

No it doesn't work correctly!

This isn't related to two-factor-auth. You have a challenge to resolve. Although it doesn't work always, try using ig.challenge.auto(true).

iSeanWeiDev commented 4 years ago

image

This code already worked in serveral days ago, but currently it is not available to access the Instagram.

Nerixyz commented 4 years ago

You need to call it after you login, so the instance can access the state data.

iSeanWeiDev commented 4 years ago

Sorry Nerixyz, It's terrible to access the state as well, actually, I had spend much time on this module to create my own bot before, currently instagram had been changed something to access his api. If you can, please check the this module. image

Nerixyz commented 4 years ago

It isn't executed. Try putting it in a catch block like

login(...).catch(e =>{ console.log('challenge');
ig.challenge.auto(true);
});
iSeanWeiDev commented 4 years ago

image

image

iSeanWeiDev commented 4 years ago

Still not working for me, You should check again for me. Several times(more than 30 times using 3 account) I had been tried to implement the features but not available, In fact, I did something about Direct message and commenting using this API in 4 dyas ago.

Actually I am very familiar with 0.10.6 before building the api using typescript. At that time, I had seen this kinds of issues on Instagram, but that was worked if I click the button "It was me".

Logandata commented 4 years ago

i meet same mistaken, can't how to fix

import 'dotenv/config'; import { IgApiClient,} from '../src'; // import * as Bluebird from 'bluebird'; // tslint:disable-next-line:no-var-requires const shttps = require('socks-proxy-agent'); // you should install SOCKS5 client via: npm i socks-proxy-agent (async () => { const ig = new IgApiClient(); // ig.challenge.auto(true); ig.state.generateDevice(process.env.IG_USERNAME); ig.request.defaults.agentClass = shttps; // apply agent class to request library defaults ig.request.defaults.agentOptions = { // @ts-ignore hostname: '127.0.0.1', // proxy hostname port: 3080, // proxy port protocol: 'socks:' // supported: 'socks:' , 'socks4:' , 'socks4a:' , 'socks5:' , 'socks5h:' };

const auth = await ig.account.login( process.env.IG_USERNAME, process.env.IG_PASSWORD).catch( async e => { console.error(e); await ig.challenge.auto(true) });

console.log(auth); // Do your things. })();

when i use ts-node xx.ts, i got there mistaken:

IgResponseError: POST /api/v1/accounts/login/ - 400 Bad Request; at Request.handleResponseError (D:\DemoProject\VUE\instagram_api\instagram-private-api\src\core\request.ts:138:12) at Request.send (D:\DemoProject\VUE\instagram_api\instagram-private-api\src\core\request.ts:77:24) (node:9256) UnhandledPromiseRejectionWarning: IgNoCheckpointError: No checkpoint data available at ChallengeRepository.auto (D:\DemoProject\VUE\instagram_api\instagram-private-api\src\repositories\challenge.repository.ts:82:13) at ig.account.login.catch (D:\DemoProject\VUE\instagram_api\instagram-private-api\examples\socks5-proxy.example.ts:24:62) (node:9256) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async func tion without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:9256) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handl ed will terminate the Node.js process with a non-zero exit code.

GianMariaPandolfi commented 4 years ago

https://github.com/dilame/instagram-private-api/blob/master/examples/checkpoint.example.ts Try to use the login catch of the example above, I resolved using it @panamacheng

Androz2091 commented 4 years ago

I'm getting the same error but just with

Capture d’écran 2019-12-21 à 10 43 48

I don't know what I can do... And my login activities on instagram.com there's nothing so I don't think it's a challenge problem

Androz2091 commented 4 years ago

Fixed by downgrading instagram_mqtt

vpaflah commented 3 years ago

Thank you all for the support