dilame / instagram-private-api

NodeJS Instagram private API SDK. Written in TypeScript.
MIT License
5.99k stars 1.14k forks source link

AuthenticationError: Login required to process this request after successful challenge #540

Closed maxkipila closed 5 years ago

maxkipila commented 6 years ago

Hello. I get "AuthenticationError: Login required to process this request" after I try to follow one random person after successful challenge. Is there anyone experiencing the same problem? The thing is, that when I tried this about one month before, It was working fine. Some instagram/cookies changes?

gold24park commented 6 years ago

I have same issue. Deleting cookie file doesn't work.

checho221 commented 6 years ago

i have similar issues but not always, so when it happends i use a backup of first successful cookies

gold24park commented 6 years ago

@checho221 what if the error occurs first login...?

checho221 commented 6 years ago

@lx5475 i does not happends to me, unless wrong password

petrNikolaev1 commented 6 years ago

Absolutely the same issue.

n0ise9914 commented 6 years ago

Same issue here, i can't login any account anyway Asking for challenge again and again...

gold24park commented 6 years ago

Once bypass the challenge, we can get cookie sessionid, mid, csrftoken, and ds_user_id.

I made my own instagram api request like/follow/comment using that cookie properties, it's work. actually my API signIn again internally (not using the cookies acquired from this library) but I use huttarichard/instagram-private-api to bypass the challenge.

requestLike(mediaId) {
        return new Promise((resolve, reject) => {
            var headers = this.getCommonHeaders();
            headers["cookie"] = this.getRequestCookie();
            request.post({
                headers: headers,
                uri: INSTAGRAM_ROOT + '/web/likes/' + mediaId + '/like/'
            }, (err, res, body) => {
                try {
                    let error = this.authenticate(res, body);
                    if (err || error) return reject(err || error);
                    return resolve(res.statusCode == 200);
                } catch (err) {
                    return reject(err);
                }
            });
        });
    }
getCommonHeaders() {
        var header = {};
        header["content-type"] = "application/x-www-form-urlencoded; charset=utf-8";
        header["accept-encoding"] = "deflate";
        header["accept-language"] = "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4";
        header["origin"] = INSTAGRAM_ROOT;
        header["referer"] = INSTAGRAM_ROOT;
        header["user-agent"] = " ";
        header["x-instagram-ajax"] = "1";
        header["x-requested-with"] = "XMLHttpRequest";
        header["x-csrftoken"] = this.cookie["csrftoken"];
        return header;
    }
diegosquid commented 6 years ago

Hey guys, I was facing the same error. I was able to fix it forcing a login before any follow / comment / like action

let session = await Client.Session.create(device, storage, account.name, account.password); await Client.Session.login(session, account.name, account.password); let relation = await Client.Relationship.create(session, userId);

sadra commented 6 years ago

Hey guys, I was facing the same error. I was able to fix it forcing a login before any follow / comment / like action

let session = await Client.Session.create(device, storage, account.name, account.password); await Client.Session.login(session, account.name, account.password); let relation = await Client.Relationship.create(session, userId);

I've tried that, and I got this error: CheckpointError: Instagram call checkpoint for this action!

So what should I do now?

ifedapoolarewaju commented 6 years ago

guys, I have fixed this issue in my PR https://github.com/huttarichard/instagram-private-api/pull/567 and I am using this fix fine on my fork here https://github.com/ifedapoolarewaju/instagram-private-api/tree/fix-challenge-issue

sadra commented 6 years ago

guys, I have fixed this issue in my PR #567 and I am using this fix fine on my fork here https://github.com/ifedapoolarewaju/instagram-private-api/tree/fix-challenge-issue

How can I use this? How solve the issue? Just passing the challenge?

ifedapoolarewaju commented 6 years ago

just use the checkpoint API the way it was already documented (but this time you are using the fork instead, or the commit to this PR https://github.com/huttarichard/instagram-private-api/pull/567), and you won't get the error anymore