Nodejs instagram-web can t save login session locally

0 votes

I recently got instagram-web from https://github.com/jlobos/instagram-web-api and have thoroughly loved it; however, I have a concern about how to store my Instagram session on a NodeJS server. According to the manual, the login process should be as follows:

let client = new instagram({username: username, password: password});
let user = await client.login();

This method will log me into Instagram, and then I'll be able to use client to call other functions, such as client. addComment() is a client function. ... follow()...

However, there is a minor issue: Instagram may occasionally block login() if I log in multiple times. As a result, I was attempting to save Instagram client data as json, locally after login, to avoid this issue and being blocked. So I write a method to log in and save the client in a.json file, and I can actually do it:

async function login(username, password) {
    const exist = fsUtil.existJson('client');
    if (!exist) {
        //create new client
        let client = new instagram({username: username, password: password});
        let user = await client.login();
       
        console.log(user)
        console.log(client)
        //saving client data as json
        fsUtil.createJson('client', client);
        return fsUtil.getJson('client');
    } else {
        //get client json data
        return fsUtil.getJson('client');
    }
}

As a result, I've just designed a technique to save it as json, and my intention is to use this client. Allows to perform instagram api requests without having to log in every time, minimising the chance that Instagram will detect I'm using a third-party software.

When I create a new client, const client = new instagram(username: username, password: password); the problem occurs. How can I use the json data I generated before for this client while maintaining the same login session and not having to log in to my Instagram account every time? I tried to make a reverse engineer in this npm module's source code, but I'm not sure how to do it.

May 27, 2022 in Node-js by Vaani
• 7,020 points
811 views

1 answer to this question.

0 votes

There are several things you can do:

  • Dictionary the user (and maybe the client) object. The hash of username+password is the key, while the value is the user object itself. So we can get it whenever we need it.
     
  • Create your own user object to serialise. This answer will assist you with serialisation if you completed the reverse engineer challenge.
answered May 27, 2022 by Neha
• 9,060 points

Related Questions In Node-js

0 votes
1 answer

Can't Upload Image with Google Photos API using NodeJS

The Google Photos API requires binary-formatted material, ...READ MORE

answered Jun 10, 2022 in Node-js by Neha
• 9,060 points
1,123 views
0 votes
1 answer

How to make login with Nodejs and MongoDB?

MongoDB Login and Registration with Node js ...READ MORE

answered Jun 16, 2022 in Node-js by Neha
• 9,060 points
9,651 views
0 votes
1 answer

nodejs robinhood api login

If you're utilising the Robinhood API, you'll ...READ MORE

answered Jun 17, 2022 in Node-js by Neha
• 9,060 points
952 views
0 votes
0 answers

Instagram API not working via Nodejs

Here is my http POST code, running ...READ MORE

Aug 19, 2022 in Node-js by Neha
• 9,060 points
417 views
0 votes
1 answer

Start script missing error when running npm start

It seems that there is an undefined ...READ MORE

answered Feb 10, 2022 in Java by Soham
• 9,700 points
4,074 views
0 votes
0 answers

Error: Can't set headers after they are sent to the client

I am using Node.js 4.10 and Express ...READ MORE

May 7, 2022 in Java-Script by narikkadan
• 63,420 points
1,149 views
0 votes
0 answers

TypeError: Router.use() requires middleware function but got a Object

There were some changes made in the ...READ MORE

May 12, 2022 in Java-Script by Kichu
• 19,050 points
7,061 views
0 votes
1 answer

What is the role of Nodejs and Express in a MERN stack web application when GraphQL is also used?

Node.js is a JavaScript runtime environment, which ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,060 points
2,164 views
0 votes
1 answer

Nodejs Instagram videos downloader not working

Firstly, Initialize a package.json file with default values. npm ...READ MORE

answered Jun 9, 2022 in Node-js by Neha
• 9,060 points
975 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP