jlobos / instagram-web-api

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

UnhandledPromiseRejectionWarning: StatusCodeError: 403 - "{\"message\":\"login_required\",\"status\":\"fail\"}" #268

Open Deivesilvaka opened 3 years ago

Deivesilvaka commented 3 years ago

(node:16500) UnhandledPromiseRejectionWarning: StatusCodeError: 403 - "{\"message\":\"login_required\",\"status\":\"fail\"}" at new StatusCodeError (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request-promise-core\lib\errors.js:32:15) at Request.plumbing.callback (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request-promise-core\lib\plumbing.js:104:33) at Request.RP$callback [as _callback] (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request-promise-core\lib\plumbing.js:46:31) at Request.self.callback (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request\request.js:185:22) at Request.emit (events.js:400:28) at Request. (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request\request.js:1154:10) at Request.emit (events.js:400:28) at IncomingMessage. (C:\Users\luidavidas\Desktop\Case - Instagram\node_modules\request\request.js:1076:12)
at Object.onceWrapper (events.js:519:28) at IncomingMessage.emit (events.js:412:35) (Use node --trace-warnings ... to show where the warning was created) (node:16500) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:16500) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Deivesilvaka commented 3 years ago

I've already logged in, but this error still gives.

yogipw commented 3 years ago

Same

RasmonT commented 3 years ago

Try this for authentication

index.js

const Instagram = require('instagram-web-api')
const dotenv = require('dotenv');
dotenv.config({ path: './process.env' });
const username = process.env.IGUSERNAME
const password = process.env.IGPASSWORD

const IGclient = new Instagram({ username, password })

IGclient
  .login()
  .then(() => {
    IGclient
      .getProfile()
      .then(console.log)
  })

put this to process.env in your directory:

 IGUSERNAME=YOURINSTAGRAMUSERNAME
 IGPASSWORD=YOURINSTAGRAMPASSWORD

it will return your instagram data.

Sirius3615 commented 2 years ago

Same issue, I trued getting profile and it returns me an undefined value in the console.

Sirius3615 commented 2 years ago

Figured it out, I forgot I changed Instagram username and didn't update it in my .env file. 😝

fulviocesile commented 2 years ago

same also for me or better it work for some time and after 10/15 times I got the error 403. If I wait some hours/days it works again