Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Post API no longer working, "ChallengeChoice.EMAIL" and "You've Been Logged Out" #62

Open
oliveirabruno01 opened this issue Jul 28, 2023 · 2 comments
Labels
question Further information is requested

Comments

@oliveirabruno01
Copy link

oliveirabruno01 commented Jul 28, 2023

Since today morning I can't post using this API anymore. It requests an email challenge, but after I enter the required code it raises this error:

[ERROR]  Request Failed, got back: [{'message': 'login_required', 'error_title': "You've Been Logged Out", 'error_body': 'Please log back in.', 'logout_reason': 8, 'status': 'fail'}]

Also, sometimes it's triggering a security alert on instagram/threads.net, and I need to change the password (already changed it sometimes but still not working).

Update: sometimes it raises this error instead:

Exception: Request Failed, got back: [{'message': 'Please wait a few minutes before you try again.', 'status': 'fail'}]
@PDGIII
Copy link

PDGIII commented Jul 30, 2023

I'm getting flagged all the time and can't seem to figure out 2FA also.

@Danie1
Copy link
Owner

Danie1 commented Aug 4, 2023

Hey, it seems to be an issue in the way you are logging in and not the Post API.
I highly recommend that once you are logged in you always use the cached token. I am still using the same token from a week ago.

Regarding customization for the login (email challenge, sms, 2FA, ... etc):
By customizing the http client you will be able to specify additional arguments to the Instagrapi API.

def auth(self, **kwargs):
        # restore original headers for Instagram login
        self._instagrapi_client.private.headers = self._instagrapi_headers
        self._instagrapi_client.challenge_code_handler = challenge_code_handler
        self._instagrapi_client.change_password_handler = change_password_handler
        self._instagrapi_client.login(**kwargs)
        token = self._instagrapi_client.private.headers['Authorization'].split("Bearer IGT:2:")[1]

        # override with Threads headers
        self._instagrapi_client.private.headers = self._threads_headers
        
        return token

Note that you can override the whole authentication mechanism this way to fit your needs.

You are welcome to open a PR with your custom http client for others to use. 😃

@Danie1 Danie1 added the question Further information is requested label Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants