Androz2091 / insta.js

💬 Object-oriented library for sending and receiving messages via Instagram
137 stars 42 forks source link

Can't authorize Client - 401 Unauthorized #84

Open ValentinLipai opened 1 year ago

ValentinLipai commented 1 year ago

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 commented 1 year ago

Update:

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

arnaudderison commented 1 year ago

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

ValentinLipai commented 1 year ago

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