jlobos / instagram-web-api

🤳 Instagram Private Web API client for Node
https://npmjs.com/instagram-web-api
MIT License
1.12k stars 186 forks source link

How update challenge? #62

Closed ghost closed 6 years ago

ghost commented 6 years ago

I have problem with updateChallenge

My code:

static async login(username, password) {
    const cookieStore = new FileCookieStore(`/path_here/${username}.json`);
    const client = new Instagram({ username, password, cookieStore });

 try {
        await client.login();
        const profile = await client.getProfile();
        console.log(profile);
      }
      catch (e) {
          this.challenges[username] = e.error.checkpoint_url;
          let challengeUrl = e.error.checkpoint_url;
          await client.updateChallenge({challengeUrl, choice: 1}); // 1 is email
          return {result: false};
      }
}

After login(username, password) I get an email with code

Now i can try update challenge:

 static async challenge(username, password, code){
    const cookieStore = new FileCookieStore(`/path_here/${username}.json`);
    const client = new Instagram({ username, password, cookieStore });

   try {
      let challengeUrl = this.challenges[username];
      console.log(challengeUrl); // here link like  /challenge/1623843519/Sz6xLG84Th/
      console.log("code " + code); // here code from email like 604861
      await client.updateChallenge({ challengeUrl, securityCode: code });
    } catch(e){
      console.log(e.error);
    }
}

When i call challenge(username, password, code) i getting error with HTML:

<!DOCTYPE html>

Page Not Found • Instagram (looks like default 404 page) Also i can open link "instagram.com" + challengeUrl and it its valid page with code form What i doing wrong? P.S. Sorry for bad English
ghost commented 6 years ago

I solved the problem. I used the version from NPM without cookie fix #58 I apologize for my carelessness

Thanks for great project! :)