stanvanrooy / instauto

Simple to use wrapper around the private Instagram API, written in Python.
https://instauto.readthedocs.io
MIT License
105 stars 24 forks source link

Login Error (KeyError: 'logged_in_user') #90

Closed markdrrr closed 3 years ago

markdrrr commented 4 years ago

image

I try to login, receive an SMS, send a number from SMS and get an error

markdrrr commented 4 years ago

@stanvanrooy how to pass authorization if you ask for SMS confirmation ?

stanvanrooy commented 4 years ago

Could you send the debug logs? Looks like the login doesn't go through fully.

markdrrr commented 4 years ago

@stanvanrooy my code:

import os

from instauto.api.client import ApiClient
from instauto.api import structs as st
from instauto.api.actions import post as ps

if __name__ == '__main__':
    if os.path.isfile('./.instauto.save'):
        client = ApiClient.initiate_from_file('./.instauto.save')
    else:
        client = ApiClient(user_name='######', password="######")
        client.login()
        client.save_to_disk('./.instauto.save')

    post = ps.PostFeed(
        path='./1.jpg',
        caption='This is an example. Follow me!'
    )
    resp = client.post_post(post, 80)
    print("Success: ", resp.ok)

logs:

C:\Users\Xiaomi\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/Xiaomi/PycharmProjects/test/test2.py
Type the security code here: 539840
Traceback (most recent call last):
  File "C:/Users/Xiaomi/PycharmProjects/test/test2.py", line 12, in <module>
    client.login()
  File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\instauto\api\actions\authentication.py", line 65, in login
    self.state.logged_in_account_data = LoggedInAccountData(**resp.json()['logged_in_user'])
KeyError: 'logged_in_user'

Process finished with exit code 1
stanvanrooy commented 4 years ago

Debug output Add the following snippet of code to your script and post the output here. Make sure to remove any passwords, etc.

import logging​
​logging​.​basicConfig​()
​logging​.​getLogger​(​''​).​setLevel​(​logging​.​DEBUG​)
markdrrr commented 4 years ago

@stanvanrooy

C:\Users\Xiaomi\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/Xiaomi/PycharmProjects/test/test2.py
INFO:instauto.api.client:No state provided. Logging in...
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): i.instagram.com:443
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "GET /api/v1/zr/token/result/?device_id=android-d54347fc8895666f&token_hash=&custom_device_id=5c96da70-d543-47fc-8895-666fbe8516c1&fetch_reason=token_expired HTTP/1.1" 200 207
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/zr/token/result/?device_id=android-d54347fc8895666f&token_hash=&custom_device_id=5c96da70-d543-47fc-8895-666fbe8516c1&fetch_reason=token_expired, method: GET with data: 
 {}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: GET
URL: https://i.instagram.com/api/v1/zr/token/result/?device_id=android-d54347fc8895666f&token_hash=&custom_device_id=5c96da70-d543-47fc-8895-666fbe8516c1&fetch_reason=token_expired
DATA: {}
HEADERS: {'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL', 'accept-encoding': 'gzip, deflate', 'x-fb-http-engine': 'Liger', 'x-ig-connection-speed': '1629kbps', 'x-ig-bandwidth-speed-kbps': '1530.373', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0'}
RESPONSE: b'{"token": {"carrier_name": "", "carrier_id": 1419, "ttl": 72000, "features": [], "request_time": 1603657714, "token_hash": "", "rewrite_rules": [], "enabled_wallet_defs_keys": [], "deadline": "", "zero_cms_fetch_interval_seconds": 86400, "carrier_signal_config": []}, "status": "ok"}'
******************** END REQUEST ********************
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /api/v1/qe/sync/ HTTP/1.1" 200 561
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/qe/sync/, method: POST with data: 
 {'_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', 'id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'sever_config_retrieval': '1', 'experiments': 'ig_android_device_detection_info_upload,ig_android_gmail_oauth_in_reg,ig_android_account_linking_upsell_universe,ig_android_direct_main_tab_universe_v2,ig_android_sign_in_help_only_one_account_family_universe,ig_android_sms_retriever_backtest_universe,ig_android_vc_interop_use_test_igid_universe,ig_android_direct_add_direct_to_android_native_photo_share_sheet,ig_growth_android_profile_pic_prefill_with_fb_pic_2,ig_account_identity_logged_out_signals_global_holdout_universe,ig_android_notification_unpack_universe,ig_android_quickcapture_keep_screen_on,ig_android_device_based_country_verification,ig_android_login_identifier_fuzzy_match,ig_android_reg_modularization_universe,ig_android_video_render_codec_low_memory_gc,ig_android_device_verification_separate_endpoint,ig_android_email_fuzzy_matching_universe,ig_android_suma_landing_page,ig_android_smartlock_hints_universe,ig_android_video_ffmpegutil_pts_fix,ig_android_multi_tap_login_new,ig_android_retry_create_account_universe,ig_android_caption_typeahead_fix_on_o_universe,ig_android_enable_keyboardlistener_redesign,ig_android_reg_nux_headers_cleanup_universe,ig_android_get_cookie_with_concurrent_session_universe,ig_android_nux_add_email_device,ig_android_device_info_foreground_reporting,ig_android_shortcuts_2019,ig_android_device_verification_fb_signup,ig_android_passwordless_account_password_creation_universe,ig_android_black_out_toggle_universe,ig_video_debug_overlay,ig_android_ask_for_permissions_on_reg,ig_assisted_login_universe,ig_android_security_intent_switchoff,ig_android_recovery_one_tap_holdout_universe,ig_android_sim_info_upload,ig_android_mobile_http_flow_device_universe,ig_android_fb_account_linking_sampling_freq_universe,ig_android_access_flow_prefill'}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: POST
URL: https://i.instagram.com/api/v1/qe/sync/
DATA: {'_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', 'id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'sever_config_retrieval': '1', 'experiments': 'ig_android_device_detection_info_upload,ig_android_gmail_oauth_in_reg,ig_android_account_linking_upsell_universe,ig_android_direct_main_tab_universe_v2,ig_android_sign_in_help_only_one_account_family_universe,ig_android_sms_retriever_backtest_universe,ig_android_vc_interop_use_test_igid_universe,ig_android_direct_add_direct_to_android_native_photo_share_sheet,ig_growth_android_profile_pic_prefill_with_fb_pic_2,ig_account_identity_logged_out_signals_global_holdout_universe,ig_android_notification_unpack_universe,ig_android_quickcapture_keep_screen_on,ig_android_device_based_country_verification,ig_android_login_identifier_fuzzy_match,ig_android_reg_modularization_universe,ig_android_video_render_codec_low_memory_gc,ig_android_device_verification_separate_endpoint,ig_android_email_fuzzy_matching_universe,ig_android_suma_landing_page,ig_android_smartlock_hints_universe,ig_android_video_ffmpegutil_pts_fix,ig_android_multi_tap_login_new,ig_android_retry_create_account_universe,ig_android_caption_typeahead_fix_on_o_universe,ig_android_enable_keyboardlistener_redesign,ig_android_reg_nux_headers_cleanup_universe,ig_android_get_cookie_with_concurrent_session_universe,ig_android_nux_add_email_device,ig_android_device_info_foreground_reporting,ig_android_shortcuts_2019,ig_android_device_verification_fb_signup,ig_android_passwordless_account_password_creation_universe,ig_android_black_out_toggle_universe,ig_video_debug_overlay,ig_android_ask_for_permissions_on_reg,ig_assisted_login_universe,ig_android_security_intent_switchoff,ig_android_recovery_one_tap_holdout_universe,ig_android_sim_info_upload,ig_android_mobile_http_flow_device_universe,ig_android_fb_account_linking_sampling_freq_universe,ig_android_access_flow_prefill'}
HEADERS: {'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '3279kbps', 'x-ig-bandwidth-speed-kbps': '3007.123', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'x-ig-android-id': 'android-d54347fc8895666f', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X5Xf8gABAAErxkRWn6zIYmm_HOWb', 'ig-u-rur': '', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:', 'connection': 'close', 'x-pigeon-session-id': '7e583505-5d8f-497c-b12a-bff7b31acda4', 'x-pigeon-rawclienttime': '1603657719.497', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'{"experiments": [{"name": "ig_android_gmail_oauth_in_reg", "group": "rollout_1201", "additional_params": [], "params": [{"name": "try_background_confirm", "value": "true"}]}, {"name": "ig_android_account_linking_upsell_universe", "group": "control", "additional_params": [], "params": [{"name": "logout_impression_limit", "value": "0"}]}, {"name": "ig_android_direct_add_direct_to_android_native_photo_share_sheet", "group": "test", "additional_params": [], "params": [{"name": "is_enabled", "value": "true"}]}, {"name": "ig_android_quickcapture_keep_screen_on", "group": "test", "additional_params": [], "params": [{"name": "keep_screen_on_enabled", "value": "true"}]}, {"name": "ig_android_video_ffmpegutil_pts_fix", "group": "test", "additional_params": [], "params": [{"name": "retry_count", "value": "5"}]}, {"name": "ig_android_multi_tap_login_new", "group": "test", "additional_params": [], "params": [{"name": "enabled", "value": "true"}, {"name": "show_logged_out_only", "value": "true"}]}, {"name": "ig_android_get_cookie_with_concurrent_session_universe", "group": "test", "additional_params": [], "params": [{"name": "is_enabled", "value": "true"}]}, {"name": "ig_android_passwordless_account_password_creation_universe", "group": "test_one_tap_check_box_shown", "additional_params": [], "params": [{"name": "upsell_for_mac_flow", "value": "true"}, {"name": "show_save_password_checkbox", "value": "true"}]}, {"name": "ig_android_ask_for_permissions_on_reg", "group": "test_email_only", "additional_params": [], "params": [{"name": "phone", "value": "false"}, {"name": "email", "value": "true"}]}, {"name": "ig_android_security_intent_switchoff", "group": "allusers", "additional_params": [], "params": [{"name": "switch_offs", "value": ""}]}, {"name": "ig_android_sim_info_upload", "group": "test", "additional_params": [], "params": [{"name": "enable_upload", "value": "true"}]}, {"name": "ig_android_fb_account_linking_sampling_freq_universe", "group": "test", "additional_params": [], "params": [{"name": "freq", "value": "100"}]}, {"name": "ig_android_access_flow_prefill", "group": "launch", "additional_params": [], "params": [{"name": "is_enabled", "value": "true"}, {"name": "long_timeout", "value": "true"}]}], "status": "ok"}'
******************** END REQUEST ********************
DEBUG:urllib3.connectionpool:Resetting dropped connection: i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /api/v1/accounts/login/ HTTP/1.1" 400 461
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/accounts/login/, method: POST with data: 
 {'ig_sig_key_version': '4', 'signed_body': 'SIGNATURE.{"jazoest": "22206", "phone_id": "348c2673-2814-4b67-9d99-d7291295d0df", "device_id": "android-d54347fc8895666f", "guid": "9726c123-dba7-44a3-8b40-74dff4c0c22b", "_csrftoken": "zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw", "adid": "f597b3a5-42fa-4e42-9804-fe2b9951c0a3", "google_tokens": "[]", "username": "####", "country_codes": "[{\\"country_code\\":\\"31\\",\\"source\\": \\"default\\"}]", "enc_password": "#PWD_INSTAGRAM:4:1603657719:AdjAA8WLde50aWf085wAAYf24el9DyZ19S1DrTA+ucjzS2OyZ2Vn4kR82FdOzqeu6oTpKJzXO627khgKrRsaeS0NgOqH+4An8k8dBCLes8SXQKZmw2t5thXguXX5EoobLFSGDVDhdmB6a2FhtO9ChHtXyuowiuav/0k8cNWYrYr1bAyCYoCpR7g6cxTP+DPBBAAu/pfqgbGKtxHJFMuRPfNZHgf4lavWuLtQljEwgmqKDDcB+m9gtoiT/PH+BC7+iqqT/e1Ka912h2TCWauHYl/e59Z5xhVe3UN+WnjleZJkXxOc1riFEMDTyExcdGjchpr26M1g7FrVYF4Hv0i0nV31iCIsd/YJ1u0wK7cCe6hlJVgnLdTgwUhCESVisg80RFBBhoCD9A==", "login_attempt_count": "0"}'}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: POST
URL: https://i.instagram.com/api/v1/accounts/login/
DATA: {'ig_sig_key_version': '4', 'signed_body': 'SIGNATURE.{"jazoest": "22206", "phone_id": "348c2673-2814-4b67-9d99-d7291295d0df", "device_id": "android-d54347fc8895666f", "guid": "9726c123-dba7-44a3-8b40-74dff4c0c22b", "_csrftoken": "zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw", "adid": "f597b3a5-42fa-4e42-9804-fe2b9951c0a3", "google_tokens": "[]", "username": "####", "country_codes": "[{\\"country_code\\":\\"31\\",\\"source\\": \\"default\\"}]", "enc_password": "#PWD_INSTAGRAM:4:1603657719:AdjAA8WLde50aWf085wAAYf24el9DyZ19S1DrTA+ucjzS2OyZ2Vn4kR82FdOzqeu6oTpKJzXO627khgKrRsaeS0NgOqH+4An8k8dBCLes8SXQKZmw2t5thXguXX5EoobLFSGDVDhdmB6a2FhtO9ChHtXyuowiuav/0k8cNWYrYr1bAyCYoCpR7g6cxTP+DPBBAAu/pfqgbGKtxHJFMuRPfNZHgf4lavWuLtQljEwgmqKDDcB+m9gtoiT/PH+BC7+iqqT/e1Ka912h2TCWauHYl/e59Z5xhVe3UN+WnjleZJkXxOc1riFEMDTyExcdGjchpr26M1g7FrVYF4Hv0i0nV31iCIsd/YJ1u0wK7cCe6hlJVgnLdTgwUhCESVisg80RFBBhoCD9A==", "login_attempt_count": "0"}'}
HEADERS: {'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '2467kbps', 'x-ig-bandwidth-speed-kbps': '4653.846', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'x-ig-android-id': 'android-d54347fc8895666f', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X5Xf8gABAAErxkRWn6zIYmm_HOWb', 'ig-u-rur': '', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:', 'connection': 'close', 'x-pigeon-session-id': '7e583505-5d8f-497c-b12a-bff7b31acda4', 'x-pigeon-rawclienttime': '1603657719.774', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'{"message": "challenge_required", "challenge": {"url": "https://i.instagram.com/challenge/5551906731/Zc0afFT3rv/", "api_path": "/challenge/5551906731/Zc0afFT3rv/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true, "flow_render_type": 0, "challenge_context": "{\\"step_name\\": \\"\\", \\"nonce_code\\": \\"Zc0afFT3rv\\", \\"user_id\\": 5551906731, \\"is_stateless\\": false}"}, "status": "fail", "error_type": "checkpoint_challenge_required"}'
******************** END REQUEST ********************
DEBUG:urllib3.connectionpool:Resetting dropped connection: i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "GET /api/v1/challenge/5551906731/Zc0afFT3rv/?guid=9726c123-dba7-44a3-8b40-74dff4c0c22b&device_id=5c96da70-d543-47fc-8895-666fbe8516c1 HTTP/1.1" 200 311
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/?guid=9726c123-dba7-44a3-8b40-74dff4c0c22b&device_id=5c96da70-d543-47fc-8895-666fbe8516c1, method: GET with data: 
 {}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: GET
URL: https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/?guid=9726c123-dba7-44a3-8b40-74dff4c0c22b&device_id=5c96da70-d543-47fc-8895-666fbe8516c1
DATA: {}
HEADERS: {'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '2128kbps', 'x-ig-bandwidth-speed-kbps': '1438.620', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'x-ig-android-id': 'android-d54347fc8895666f', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X5Xf8gABAAErxkRWn6zIYmm_HOWb', 'ig-u-rur': '', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:', 'connection': 'close', 'x-pigeon-session-id': '7e583505-5d8f-497c-b12a-bff7b31acda4', 'x-pigeon-rawclienttime': '1603657722.702', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com'}
RESPONSE: b'{"step_name": "select_verify_method", "step_data": {"choice": "0", "fb_access_token": "None", "big_blue_token": "None", "google_oauth_token": "true", "vetted_device": "None", "phone_number": "+7 *** ***-**-12"}, "flow_render_type": 3, "bloks_action": "com.instagram.challenge.navigation.take_challenge", "nonce_code": "Zc0afFT3rv", "user_id": 5551906731, "challenge_context": "{\\"step_name\\": \\"select_verify_method\\", \\"nonce_code\\": \\"Zc0afFT3rv\\", \\"user_id\\": 5551906731, \\"is_stateless\\": false}", "status": "ok"}'
******************** END REQUEST ********************
DEBUG:urllib3.connectionpool:Resetting dropped connection: i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /api/v1/challenge/5551906731/Zc0afFT3rv/ HTTP/1.1" 200 318
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/, method: POST with data: 
 {'choice': 0, '_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', '_uuid': '9726c123-dba7-44a3-8b40-74dff4c0c22b', 'bloks_versioning_id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'post': 1}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: POST
URL: https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/
DATA: {'choice': 0, '_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', '_uuid': '9726c123-dba7-44a3-8b40-74dff4c0c22b', 'bloks_versioning_id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'post': 1}
HEADERS: {'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '1098kbps', 'x-ig-bandwidth-speed-kbps': '1543.989', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'x-ig-android-id': 'android-d54347fc8895666f', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X5Xf8gABAAErxkRWn6zIYmm_HOWb', 'ig-u-rur': '', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:', 'connection': 'close', 'x-pigeon-session-id': '7e583505-5d8f-497c-b12a-bff7b31acda4', 'x-pigeon-rawclienttime': '1603657723.863', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'{"step_name": "verify_code", "step_data": {"security_code": "None", "sms_resend_delay": 60, "phone_number_preview": "8-12", "resend_delay": 60, "contact_point": "8-12", "form_type": "phone_number", "phone_number_formatted": "+7 *** ***-88-12", "phone_number": "+7 *** ***-88-12"}, "flow_render_type": 3, "bloks_action": "com.instagram.challenge.navigation.take_challenge", "nonce_code": "Zc0afFT3rv", "user_id": 5551906731, "challenge_context": "{\\"step_name\\": \\"verify_code\\", \\"nonce_code\\": \\"Zc0afFT3rv\\", \\"user_id\\": 5551906731, \\"is_stateless\\": false}", "status": "ok"}'
******************** END REQUEST ********************
Type the security code here: 785369
DEBUG:urllib3.connectionpool:Resetting dropped connection: i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /api/v1/challenge/5551906731/Zc0afFT3rv/ HTTP/1.1" 200 730
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/, method: POST with data: 
 {'_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', '_uuid': '9726c123-dba7-44a3-8b40-74dff4c0c22b', 'bloks_versioning_id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'post': 1, 'security_code': '785369'}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: POST
URL: https://i.instagram.com/api/v1/challenge/5551906731/Zc0afFT3rv/
DATA: {'_csrftoken': 'zkQXS5ITyzykQVBcClkKwYuAlWSIEJnw', '_uuid': '9726c123-dba7-44a3-8b40-74dff4c0c22b', 'bloks_versioning_id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'post': 1, 'security_code': '785369'}
HEADERS: {'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '3195kbps', 'x-ig-bandwidth-speed-kbps': '1962.674', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': '5c96da70-d543-47fc-8895-666fbe8516c1', 'x-ig-android-id': 'android-d54347fc8895666f', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X5Xf8gABAAErxkRWn6zIYmm_HOWb', 'ig-u-rur': '', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:', 'connection': 'close', 'x-pigeon-session-id': '7e583505-5d8f-497c-b12a-bff7b31acda4', 'x-pigeon-rawclienttime': '1603657834.994', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'{"logged_in_user": {"pk": 5551906731, "username": "####", "full_name": "\\u0427\\u041f \\u041f\\u044f\\u0442\\u0438\\u0433\\u043e\\u0440\\u0441\\u043a", "is_private": true, "profile_pic_url": "https://scontent-waw1-1.cdninstagram.com/v/t51.2885-19/s150x150/71779025_2859947837467840_2921277788297201898_n.jpg?_nc_ht=scontent-waw1-1.cdninstagram.com\\u0026_nc_ohc=CWdtkyAwtB4AX8dZCyl\\u0026oh=b356b4aa1e5169d97c271e2b5a1c9918\\u0026oe=5FBF49FD", "profile_pic_id": "2342397121814465974_5551906731", "is_verified": false, "has_anonymous_profile_picture": false, "can_boost_post": false, "is_business": false, "account_type": 1, "professional_conversion_suggested_account_type": 3, "is_call_to_action_enabled": null, "can_see_organic_insights": false, "show_insights_terms": false, "total_igtv_videos": 0, "reel_auto_archive": "unset", "has_placed_orders": false, "allowed_commenter_type": "any", "nametag": {"mode": 0, "gradient": 0, "emoji": "\\ud83d\\ude00", "selfie_sticker": 0}, "is_using_unified_inbox_for_direct": false, "interop_messaging_user_fbid": 116295303088667, "can_see_primary_country_in_settings": false, "account_badges": [], "allow_contacts_sync": false, "phone_number": "+7##########", "country_code": 7, "national_number": ##########}, "action": "close", "auto_login": true, "status": "ok"}'
******************** END REQUEST ********************
Traceback (most recent call last):
  File "C:/Users/Xiaomi/PycharmProjects/test/test2.py", line 16, in <module>
    client.login()
  File "C:\Users\Xiaomi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\instauto\api\actions\authentication.py", line 65, in login
    self.state.logged_in_account_data = LoggedInAccountData(**resp.json()['logged_in_user'])
KeyError: 'logged_in_user'
stanvanrooy commented 4 years ago

Okay good, verification is working, so probably just something wrong in the logic. That's easy to fix.

I'll publish fix tomorrow.

stanvanrooy commented 4 years ago

@markdrrr nvm, this error doesn't make sense :) the response shows a logged_in_user object, but it still throws the KeyError.

Could you run the version in the 90Test branch, I've added an additional logging message there.

cheersgocheersgo commented 4 years ago

I am sorry to hear that,No body can help me:( https://github.com/stanvanrooy/instauto/issues/76