instagrapi
instagrapi copied to clipboard
[BUG] JSONDecodeError for TOTP 2FA (Google Authenticator)
I am getting a JSONDecodeError exception when I try to perform two factor authentication with Google Authenticator. Am I doing something wrong or has Instagram changed the API?
Traceback:
Status 200: JSONDecodeError in private_request (user_id=10342827286, endpoint=/challenge/) >>> <!DOCTYPE html>
(long html...)
future: <Task finished coro=<Dispatcher._process_polling_updates() done, defined at /app/.heroku/python/lib/python3.7/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=ClientJSONDecodeError('JSONDecodeError [Errno Expecting value] <!DOCTYPE html>\n<html lang="en" class="no-js logged-in client-root touch">\n <head>\n <meta charset="utf-8">\n
(long html...)
</script>\n </body>\n</html>
instagrapi.exceptions.ClientJSONDecodeError: JSONDecodeError [Errno Expecting value] <!DOCTYPE html>
(long html...)
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Expecting value] <!DOCTYPE html>
(long html...)
@hittiks it looks like instagram has changed api, can you fix it?
@adw0rd No, I can't fix it
To recreate the behavior, you need to follow the link https://i.instagram.com/challenge/?next=/api/challenge/ (after 2FA)
So I tried to run that long HTML and got this page:
https://ibb.co/1GhWPyg
I am using Heroku to run my code in the cloud and passing this challenge from mobile can't solve the problem
Button "Это я" have this code (maybe it will be useful):
<button name="choice" value="0" class="_5f5mN -fzfL KUBKM yZn4P ">Это я</button>
Same error for me
@adw0rd Well, I tried to fix it. I was able to go through that page and get {'location': 'instagram://checkpoint/dismiss', 'type': 'CHALLENGE_REDIRECTION', 'status': 'ok'}
but so far I don't understand what I need to go further
I have the same problem.
a quick fix:
pip install ensta
from ensta import Host
host = Host(username, password, totp_token=token)