dilame / instagram-private-api

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

400 Bad Request; Login Error... #1550

Open mohsen-rasouli opened 2 years ago

mohsen-rasouli commented 2 years ago

Platform

Description

When I want to login, I got this error. How can I fix that

Code

const client = new IgApiClient();

    const username = 'username';
    const password = 'password';

    client.state.generateDevice(username)

    try {
        const loggedInAccount = await client.account.login(username, password);
        await client.simulate.postLoginFlow();

        const cu = await client.account.currentUser();

        console.log({
            'prfile': cu,
        })
    } catch (e) {
        console.log(e)
    }

Error and Output

{
  error: IgResponseError: POST /api/v1/qp/batch_fetch/ - 400 Bad Request; FAILURE
      at Request.handleResponseError (C:\Users\Administrator\Desktop\node_ig\instagram-private-api\dist\core\request.js:125:16)
      at Request.send (C:\Users\Administrator\Desktop\node_ig\instagram-private-api\dist\core\request.js:53:28)
}
razzy777 commented 2 years ago

Can confirm. I'm getting the same error message.

Eniamza commented 2 years ago

Me too!

razzy777 commented 2 years ago

await client.simulate.postLoginFlow(); Removing this line worked for me and won't have any other effects.

mohsen-rasouli commented 2 years ago

await client.simulate.postLoginFlow(); Removing this line worked for me and won't have any other effects.

Work for me... Thank You!

Eniamza commented 2 years ago

await client.simulate.postLoginFlow(); Removing this line worked for me and won't have any other effects.

Are you sure for the long run? I thought it was used to simulate a real user login process.

Eniamza commented 2 years ago

Just in Case it works again in future, I wrapped up it in a try-catch so it doesn't mess up when not available

Thanks @razzy777 !

sunderee commented 2 years ago

I'm having the same issue, and this doesn't resolve it. In my case, code looks something like this:

async login(): Promise<LoginResult> {
    const username = this.configService.get <string>('USERNAME');
    const password = this.configService.get <string>('PASSWORD');
    if (username === undefined || password === undefined) {
        // handle exception...
    }

    const result = await this.instagramClient.account.login(username, password);
    return {
        username: result.username,
        fullName: result.full_name,
        profilePicURL: result.profile_pic_url,
        isAccountPrivate: result.is_private,
        isVerified: result.is_verified,
        isBusinessAccount: result.is_business
    };
}

The error I receive is

POST /api/v1/accounts/login/ - 400 Bad Request; The username you entered doesn't appear to belong to an account. Please check your username and try again.
mohsen-rasouli commented 2 years ago

I got this error again with two factor authentication! :(

The error is:

{
  error: IgResponseError: POST /api/v1/accounts/two_factor_login/ - 400 Bad Request; Please check the security code and try again.
      at Request.handleResponseError (C:\Users\Administrator\Desktop\instagram-private-api\dist\core\request.js:125:16)
      at Request.send (C:\Users\Administrator\Desktop\instagram-private-api\dist\core\request.js:53:28)
      at async AccountRepository.twoFactorLogin (C:\Users\Administrator\Desktop\instagram-private-api\dist\repositories\account.repository.js:89:26)
      at async C:\Users\Administrator\Desktop\app.js:278:36
}

And app.js is:

const twoFactorLogin = await clients[clientId].account.twoFactorLogin({
    username: tow_factor_auth[clientId].username,
    verificationCode: tow_factor_auth[clientId].two_factor_identifier_code,
    twoFactorIdentifier: tow_factor_auth[clientId].two_factor_identifier,
    verificationMethod: 1,
    trustThisDevice: 1,
});

What can I do to solve this problem?

kingbotss commented 2 years ago

You should send request as http2 instead of http. For me this is working

ThoughtI-Viral commented 4 months ago

I'm having the same issue, and this doesn't resolve it. In my case, code looks something like this:

async login(): Promise<LoginResult> {
    const username = this.configService.get <string>('USERNAME');
    const password = this.configService.get <string>('PASSWORD');
    if (username === undefined || password === undefined) {
        // handle exception...
    }

    const result = await this.instagramClient.account.login(username, password);
    return {
        username: result.username,
        fullName: result.full_name,
        profilePicURL: result.profile_pic_url,
        isAccountPrivate: result.is_private,
        isVerified: result.is_verified,
        isBusinessAccount: result.is_business
    };
}

The error I receive is

POST /api/v1/accounts/login/ - 400 Bad Request; The username you entered doesn't appear to belong to an account. Please check your username and try again.

I have same error

zakrian07 commented 4 months ago

Try to login with email ?

On Mon, May 20, 2024 at 12:35 PM ThoughtI-Viral @.***> wrote:

I'm having the same issue, and this doesn't resolve it. In my case, code looks something like this:

async login(): Promise { const username = this.configService.get ('USERNAME'); const password = this.configService.get ('PASSWORD'); if (username === undefined || password === undefined) { // handle exception... }

const result = await this.instagramClient.account.login(username, password);
return {
    username: result.username,
    fullName: result.full_name,
    profilePicURL: result.profile_pic_url,
    isAccountPrivate: result.is_private,
    isVerified: result.is_verified,
    isBusinessAccount: result.is_business
};}

The error I receive is

POST /api/v1/accounts/login/ - 400 Bad Request; The username you entered doesn't appear to belong to an account. Please check your username and try again.

I have same error

— Reply to this email directly, view it on GitHub https://github.com/dilame/instagram-private-api/issues/1550#issuecomment-2119851784, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XJJKL55EMSGHYIXQP3ZDGRSJAVCNFSM5HNLX2T2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJRHE4DKMJXHA2A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ThoughtI-Viral commented 4 months ago

Try to login with email ? On Mon, May 20, 2024 at 12:35 PM ThoughtI-Viral @.> wrote: I'm having the same issue, and this doesn't resolve it. In my case, code looks something like this: async login(): Promise { const username = this.configService.get ('USERNAME'); const password = this.configService.get ('PASSWORD'); if (username === undefined || password === undefined) { // handle exception... } const result = await this.instagramClient.account.login(username, password); return { username: result.username, fullName: result.full_name, profilePicURL: result.profile_pic_url, isAccountPrivate: result.is_private, isVerified: result.is_verified, isBusinessAccount: result.is_business };} The error I receive is POST /api/v1/accounts/login/ - 400 Bad Request; The username you entered doesn't appear to belong to an account. Please check your username and try again. I have same error — Reply to this email directly, view it on GitHub <#1550 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPI5XJJKL55EMSGHYIXQP3ZDGRSJAVCNFSM5HNLX2T2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJRHE4DKMJXHA2A . You are receiving this because you are subscribed to this thread.Message ID: @.>

Tried both : 1) Login with gmail 2) Also with instagram username

Non of them worked