Closed ondersumer07 closed 4 years ago
You're calling syncLoginExperiments()
before you're generating a device.
Yep, it was pretty late at night and I was very tired I missed that one. Here's the working code for future references:
const { IgApiClient } = require('instagram-private-api');
const { readFile } = require('fs');
const { promisify } = require('util');
const ig = new IgApiClient();
ig.state.generateDevice("username");
(async () => {
await ig.simulate.preLoginFlow();
await ig.account.login("username", "password");
console.log("logged in!")
process.nextTick(async () => await ig.simulate.postLoginFlow());
const videoPath = 'video.mp4';
const coverImage = 'thumb.jpg';
const publishResult = await ig.publish.video({
video: await readFileAsync(videoPath),
coverImage: await readFileAsync(coverImage),
caption: 'description'
});
console.log(publishResult);
})().catch(console.log);
Same thing here, Im getting it on a few new accounts. Accounts previously logged in work fine when re-logging in. I am calling loginexp second.
IgResponseError: POST /api/v1/qe/sync/ - 400 Bad Request; No ID given
at Request.handleResponseError (/srv/node_modules/instagram-private-api/dist/core/request.js:125:16)
at Request.send (/srv/node_modules/instagram-private-api/dist/core/request.js:53:28)
at
@trentona make sure you're loading and saving your state properly.
It works with fine previous accounts though? Maybe I should only be doing "const ig = new IgApiClient;" once?
Bluebird.try (async () => {
const ig = new IgApiClient;
ig.state.generateDevice(myUsername);
await ig.qe.syncLoginExperiments();
ig.state.generateDevice(String(myUsername));
ig.state.proxyUrl = process.env.IG_PROXY;
const auth = await ig.account.login(String(myUsername), String(myPassword));
console.log(JSON.stringify(auth));
}).catch(IgCheckpointError, async () => {
const ig = new IgApiClient;
Bluebird.try(async () => {
const auth = await ig.account.login(String(myUsername), String(myPassword));
console.log(auth);
console.log(ig.state.checkpoint);
await ig.challenge.auto(true);
console.log(ig.state.checkpoint);
...
Why are you generating your device twice?
Try to generate it once, this might be the issue.
Maybe I should only be doing "const ig = new IgApiClient;" once?
Your IgApiClient has all your state information. So if you create a new instance, it won't have the state.
ig.state.generateDevice(String(myUsername));
This is unnecessary.
Thanks, not sure how I did that. I get a different error now though.
I just updated and tested a new account and account I have previously used again. The new account did not work and gave me this error. Am I missing part of the challenges required? Iv gotten the otc to work before but it seems to just finish the function before the checkpointError completes. The otc was not being sent email/phone number attached to the instagram account. Instagram does notify a login attempt though, but does not supply the otc either.
Could I have flagged out the login through insta? Iv noticed about 12 posts in a hour can get your account flagged and it will auto delete your images. But I have never had issues with login like this but I feel it may be a possibility.
IgCheckpointError: POST /api/v1/accounts/login/ - 400 Bad Request; challenge_required
at Request.handleResponseError (/srv/node_modules/instagram-private-api/dist/core/request.js:107:24)
at Request.send (/srv/node_modules/instagram-private-api/dist/core/request.js:53:28)
at
.catch(IgCheckpointError, async () => {
Bluebird.try(async () => {
const auth = await ig.account.login(String(myUsername), String(myPassword));
console.log(auth);
console.log(ig.state.checkpoint); // Checkpoint info here
await ig.challenge.auto(true); // Requesting sms-code or click "It was me" button
console.log(ig.state.checkpoint); // Challenge info here
await functions.database.ref('/users/' + myUsername + '/otc')
.onCreate((snapshot, context) => {
// Grab the current value of what was written to the Realtime Database.
const code = snapshot.val();
console.log('something happened');
myCode = snapshot.val();
console.log(ig.challenge.sendSecurityCode(myCode));
I also met this problem, may I ask your final solution?
Bug Report
Form
Put an
[x]
if you meet the condition, else leave[ ]
.Requirements
DEBUG
variable.Platform
14 (node -v)
Firefox
Windows
Description
The problem is probably about API version of Instagram. I'm trying to compile TS to JS and make it work in the terminal.
Code
Error and Output