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.