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 in Node-js by Vaani
• 7,020 points
19 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 by Neha
• 8,560 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 in Node-js by Neha
• 8,560 points
17 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 in Node-js by Neha
• 8,560 points
13 views
0 votes
1 answer

nodejs robinhood api login

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

answered Jun 17 in Node-js by Neha
• 8,560 points
11 views
0 votes
1 answer

How do I “include” functions from my other files in nodejs?

Hello @kartik, You require any js file,so you just ...READ MORE

answered Jul 9, 2020 in Node-js by Niroj
• 82,700 points
1,482 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 in Java by Soham
• 8,730 points
1,791 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 in Java-Script by narikkadan
• 10,840 points
125 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 in Java-Script by Kichu
• 19,040 points
393 views
0 votes
1 answer
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 in Node-js by Neha
• 8,560 points
21 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP