Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't authorize Client - 401 Unauthorized #84

Open
ValentinLipai opened this issue Nov 6, 2022 · 3 comments
Open

Can't authorize Client - 401 Unauthorized #84

ValentinLipai opened this issue Nov 6, 2022 · 3 comments

Comments

@ValentinLipai
Copy link

ValentinLipai commented Nov 6, 2022

Do I need to prepare my account to work with insta.js?
I can't start the application

Error:

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

IgResponseError: POST /api/v1/accounts/msisdn_header_bootstrap/ - 401 Unauthorized; Please wait a few minutes before you try again.
    at Request.handleResponseError (/home/runner/InstaChatBot/node_modules/instagram-private-api/dist/core/request.js:126:16)
    at Request.send (/home/runner/InstaChatBot/node_modules/instagram-private-api/dist/core/request.js:54:28)

Code:

const Insta = require('@androz2091/insta.js');
const client = new Insta.Client();

client.on('connected', () => {
  console.log(`Logged in as ${client.user.username}`);
});

client.on('messageCreate', (message) => {
  if (message.author.id === client.user.id) return
  message.markSeen();

  if (message.content === '!ping') {
    message.reply('!pong');
  }
});

client.login(process.env.USERNAME, process.env.PASSWORD); 
@ValentinLipai
Copy link
Author

ValentinLipai commented Nov 6, 2022

Update:

Locally works fine.
I encountered this error on namecheap and replit.com

@arnaudderison
Copy link

I have the same problem. Locally it's ok but on a server it doesn't work anymore

@ValentinLipai
Copy link
Author

I have the same problem. Locally it's ok but on a server it doesn't work anymore

If I'm not mistaken, deleting await ig.simulate.preLoginFlow() helped me

https://github.com/Androz2091/insta.js/pull/69/files#diff-94d24d9a42d3b3fc4388be708ac1fbed9336f645b4380e30374ce76c2128c62a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants