From 1a3712d1128769fe2c2e3beef96635ef321ac849 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Tue, 19 May 2020 03:25:08 -0400 Subject: [PATCH] Workaround for Instagram's encrypted login. (#623) * Workaround for Instagram's encrypted login. Credit: https://github.com/pgrimaud/ See: https://github.com/pgrimaud/instagram-user-feed/commit/96ad4cf54d1ad331b337f325c73e664999a6d066 Closes #615. Co-authored-by: Alexander Graf <17130992+aandergr@users.noreply.github.com> --- instaloader/instaloadercontext.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instaloader/instaloadercontext.py b/instaloader/instaloadercontext.py index b1458ff..bb13cc9 100644 --- a/instaloader/instaloadercontext.py +++ b/instaloader/instaloadercontext.py @@ -215,8 +215,11 @@ class InstaloaderContext: session.headers.update({'X-CSRFToken': csrf_token}) # Not using self.get_json() here, because we need to access csrftoken cookie self.do_sleep() + # Workaround credits to pgrimaud. + # See: https://github.com/pgrimaud/instagram-user-feed/commit/96ad4cf54d1ad331b337f325c73e664999a6d066 + enc_password = '#PWD_INSTAGRAM_BROWSER:0:{}:{}'.format(int(datetime.now().timestamp()), passwd) login = session.post('https://www.instagram.com/accounts/login/ajax/', - data={'password': passwd, 'username': user}, allow_redirects=True) + data={'enc_password': enc_password, 'username': user}, allow_redirects=True) try: resp_json = login.json() except json.decoder.JSONDecodeError: