Giter Site home page Giter Site logo

Comments (6)

mkgerasimenko avatar mkgerasimenko commented on May 12, 2024 3

@gutosanches, I may have solved that problem with:

await client.updateChallenge({challengeUrl, choice: 1});
await client.updateChallenge({ challengeUrl, securityCode: 'VERIFICATION_CODE_FROM_EMAIL'});

In my case I need to update Challenge with security code from Instagram email.

Full code (TS):

public async login(): Promise<Instagram> {
        const client = new Instagram({username: this.username, password: this.password});
        try {
            await client.login();
        } catch (err) {
            if (err.error && err.error.message === 'checkpoint_required') {
                const challengeUrl = err.error.checkpoint_url;

                await client.updateChallenge({challengeUrl, choice: 1});
                await client.updateChallenge({ challengeUrl, securityCode: '301794'}); // <== securityCode - set code from email.
            }
        }
        return await client;
    }

Notes:

  1. I use Gmail email for Instagram.
  2. I use imap-simple for getting the Security code from Instagram Email.

from instagram-web-api.

samholmes avatar samholmes commented on May 12, 2024 1

I spent a lot of time with these challenges in order to figure out the appropriate way to use the API. First, you'll need to save the challengeUrl returned from the login form. I then use getChallenge to get the challenge JSON object. From there you can read the challengeType which will determine what do to. Here's the challengeTypes that I found:

  1. SelectVerificationMethodForm This is the form you see asking you whether to send the verification via email or mobile text. Use updateChallenge to set the choice, and after invocation, the verification email/text will be sent.
  2. VerifyEmailCodeForm This is the form you see when asking for the verification code from email. This doesn't require a choice when calling updateChallenge (in fact, I believe it will give an error). Instead, send the securityCode with the updateChallenge invocation. If no security code was sent, you can use replayChallenge to have the security code sent again.

There may be other challengeTypes worth documenting, but these are enough to get a working challenge passing algorithm started. I would log any other challenge types that aren't handled by your app, and share them with some context so we can all figure out what they mean and document them.

Cheers!

from instagram-web-api.

gutosanches avatar gutosanches commented on May 12, 2024

I'm trying to implement the flow suggested above ^ but I'm also getting that same This page could not be loaded. error (and also in HTML) when trying to call updateChallenge. Opening the challengeUrl on the browser directly shows the verification page as expected.

Anyone ran into this too and figured it out?

Here's what I'm doing:

  1. Try to login
  2. Get error with challenge_url
  3. Call updateChalenge using challengeUrl and choice 1 for email, as suggested
  4. Get error This page could not be loaded

from instagram-web-api.

lucasvieceli avatar lucasvieceli commented on May 12, 2024

I am using "imap-simple" to pick up the security code, but it is still returning error 400 :((

Google translate :D

export const getClientInstagram = async ({usuario, senha, cookie}) => {
    const contaRepository = getCustomRepository(ContaRepository);
    
    const client = new Instagram({
        username: usuario,
        password: senha,
        cookies: cookie
    }, {language: 'pt-BR'});

    try{
        const t = await client.login();
        await contaRepository.setCookiePorUsuario(usuario, t.cookies);
    }catch (err) {
        if (err.error && err.error.message === 'checkpoint_required') {
            const codigoSeguranca = await getCodigoSeguranca(usuario);
            

            if(codigoSeguranca) {
                const challengeUrl = err.error.checkpoint_url;

                await client.updateChallenge({challengeUrl, choice: 1});
                await client.updateChallenge({challengeUrl, securityCode: codigoSeguranca}); 
            }
        }
    }

    return client;
}

from instagram-web-api.

chunheisiu avatar chunheisiu commented on May 12, 2024

Same Problem. Getting 400 checkpoint_required error messages.

My app runs in a Docker container, so I haven't figured out a way to read the security code from outside and then insert it into client.updateChallenge.

Any help/suggestions are appreciated.

from instagram-web-api.

dmred avatar dmred commented on May 12, 2024

Same Problem. Getting 400 checkpoint_required error messages.

My app runs in a Docker container, so I haven't figured out a way to read the security code from outside and then insert it into client.updateChallenge.

Any help/suggestions are appreciated.

Are there any decisions after more than one year?)

from instagram-web-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.