dilame / instagram-private-api

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

SMS dont come #1442

Open Nuruddin999 opened 3 years ago

Nuruddin999 commented 3 years ago

in get serveside props i run code

 async login(): Promise<AccountRepositoryLoginResponseLogged_in_user | ErrorTwoF> {
    this.ig.state.generateDevice(this.username)
    await this.ig.simulate.preLoginFlow()
    const loggenInAccaunt = await this.ig.account.login(this.username, this.password).catch(err => {
        console.log(err)
        const { totp_two_factor_on, two_factor_identifier } = err.response.body.two_factor_info;
        this.ig.account.twoFactorLogin({ username: this.username, verificationCode: "here i paste my additional 8 number code in case when sms dont come", twoFactorIdentifier: two_factor_identifier, trustThisDevice: "1", verificationMethod: '1' }).then(r => r).catch(e => console.log("Result from 2 factor  " + e))
        return { totp_two_factor_on, two_factor_identifier }
    })

    console.log(JSON.stringify(loggenInAccaunt))
    return loggenInAccaunt
}

but sms dont come and i paste additional 8 number security code which instagram provides me when sms dont come and after that i have error Please check the security code and try again. How fix it ?

pepinogttv commented 2 years ago

Same problem

gabrielbuzziv commented 1 year ago

same

kadriudrin commented 7 months ago

Did you solve this?

Avivbens commented 1 month ago

I'm having the same issue here... Any idea? 🤷‍♂️

Here is my code

        const username = conf.get<string>(EnvVariables.INSTAGRAM_USERNAME)
        const password = conf.get<string>(EnvVariables.INSTAGRAM_PASSWORD)

        if (!username || !password) {
            throw new Error('Instagram username and password must be provided')
        }

        const ig = new IgApiClient()
        ig.state.generateDevice(username)

        /**
         * Login flow
         */
        await ig.simulate.preLoginFlow()
        await ig.account.login(username, password).catch(async (error) => {
            await ig.account
                .twoFactorLogin({
                    username,
                    verificationCode: await inquirer
                        .prompt({ type: 'input', name: 'code', message: 'Enter 2FA code' })
                        .then((a) => a.code),
                    twoFactorIdentifier: error.response.body.two_factor_info.two_factor_identifier,
                    trustThisDevice: '1',
                    verificationMethod: '1',
                })
        })

        await ig.simulate.postLoginFlow()