Open oliveirabruno01 opened 1 year ago
I'm getting flagged all the time and can't seem to figure out 2FA also.
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.
This is how you specify the HTTP client to ThreadsAPI: https://github.com/Danie1/threads-api#customize-http-client
This is how you add additional functionality to the Instagrapi login (such as email challenge response, ... etc): https://github.com/adw0rd/instagrapi/blob/master/examples/challenge_resolvers.py
This is one of the HTTP clients we provide that you can copy and modify to your needs: https://github.com/Danie1/threads-api/blob/main/threads_api/src/http_sessions/instagrapi_session.py#L24 On line 24 the .login() function is called from the Instagrapi API. You can provide the challenge handlers as described in https://github.com/adw0rd/instagrapi/blob/master/examples/challenge_resolvers.py like so:
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. 😃
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:
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: