mirror of
https://github.com/instaloader/instaloader.git
synced 2024-11-20 01:02:30 +01:00
Fixed bug that was asking for 2FA code again and again.
This commit is contained in:
parent
3cc29a4ceb
commit
9a699288e9
@ -208,6 +208,8 @@ class InstaloaderContext:
|
|||||||
'ig_vw': '1920', 'ig_cb': '1', 'csrftoken': '',
|
'ig_vw': '1920', 'ig_cb': '1', 'csrftoken': '',
|
||||||
's_network': '', 'ds_user_id': ''})
|
's_network': '', 'ds_user_id': ''})
|
||||||
session.headers.update(self._default_http_header())
|
session.headers.update(self._default_http_header())
|
||||||
|
#Getting mid cookie value
|
||||||
|
session.get("https://i.instagram.com/api/v1/web/login_page/")
|
||||||
# Override default timeout behavior.
|
# Override default timeout behavior.
|
||||||
# Need to silence mypy bug for this. See: https://github.com/python/mypy/issues/2427
|
# Need to silence mypy bug for this. See: https://github.com/python/mypy/issues/2427
|
||||||
session.request = partial(session.request, timeout=self.request_timeout) # type: ignore
|
session.request = partial(session.request, timeout=self.request_timeout) # type: ignore
|
||||||
@ -262,6 +264,7 @@ class InstaloaderContext:
|
|||||||
# username is invalid.
|
# username is invalid.
|
||||||
raise InvalidArgumentException('Login error: User {} does not exist.'.format(user))
|
raise InvalidArgumentException('Login error: User {} does not exist.'.format(user))
|
||||||
# '{"authenticated": true, "user": true, "userId": ..., "oneTapPrompt": false, "status": "ok"}'
|
# '{"authenticated": true, "user": true, "userId": ..., "oneTapPrompt": false, "status": "ok"}'
|
||||||
|
if 'csrftoken' in login.cookies:
|
||||||
session.headers.update({'X-CSRFToken': login.cookies['csrftoken']})
|
session.headers.update({'X-CSRFToken': login.cookies['csrftoken']})
|
||||||
self._session = session
|
self._session = session
|
||||||
self.username = user
|
self.username = user
|
||||||
@ -287,6 +290,7 @@ class InstaloaderContext:
|
|||||||
raise BadCredentialsException("2FA error: {}".format(resp_json['message']))
|
raise BadCredentialsException("2FA error: {}".format(resp_json['message']))
|
||||||
else:
|
else:
|
||||||
raise BadCredentialsException("2FA error: \"{}\" status.".format(resp_json['status']))
|
raise BadCredentialsException("2FA error: \"{}\" status.".format(resp_json['status']))
|
||||||
|
if 'csrftoken' in login.cookies:
|
||||||
session.headers.update({'X-CSRFToken': login.cookies['csrftoken']})
|
session.headers.update({'X-CSRFToken': login.cookies['csrftoken']})
|
||||||
self._session = session
|
self._session = session
|
||||||
self.username = user
|
self.username = user
|
||||||
|
Loading…
Reference in New Issue
Block a user