简体   繁体   中英

I'm getting the error "The username you entered doesn't appear to belong to an account" in instagram-private-api

I'm new to this library ( https://npmjs.com/instagram-private-api ). I've been trying for a while but still no success at logging in.

My code is:

import { IgApiClient } from 'instagram-private-api';
import { config } from "dotenv";
export default class BotService {
  ig: IgApiClient;
  user: string;
  password: string;
  constructor() {
  config();
    this.user = process.env.USER;
    this.password = process.env.PASS;
    this.ig = new IgApiClient();
  }

  async login(){
    await this.ig.state.generateDevice(this.user);
    await this.ig.simulate.preLoginFlow();
    const loggedInAccount = await this.ig.account.login(this.user, this.password);
    await this.ig.simulate.postLoginFlow();
    console.log(loggedInAccount.full_name);
  }
  
}

Error:

    at Request.handleResponseError (C:\Users\minsiam\Downloads\instagrem\node_modules\instagram-private-api\src\core\request.ts:172:12)
    at Request.send (C:\Users\minsiam\Downloads\instagrem\node_modules\instagram-private-api\src\core\request.ts:83:24)
[ERROR] 12:47:35 IgResponseError: POST /api/v1/accounts/login/ - 400 Bad Request; The username you entered doesn't appear to belong to an account. Please check your username and try again.

The username is correct, tried directly putting it (without env) but it still didn't work.

Damn that library. Tried for days, still no success. But I finally found a new library. ( https://www.npmjs.com/package/instauto ) It seems to be working pretty well. Maybe it was an issue of the old library? I contacted the owner and seems like he stopped working on it. It may be the library issue who knows. But yeah the question is solved now, thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM