subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

[BUG] How to resolve this type of challenge? #1619

Open funnyruler opened 1 year ago

funnyruler commented 1 year ago

Have an unexpected type of challenge - checkbox on instagram page. Got this challenge while scrapping user profiles by client.user_info(user_pk). On this url - https://i.instagram.com/api/v1/challenge/ got next answer: {"message":"checkpoint_required","checkpoint_url":"https://i.instagram.com/challenge/","lock":true,"flow_render_type":0,"status":"fail"}

Traceback with aiogram output, but it doesn't matter

public.py [ LINE:160] INFO     [2023-10-16 23:09:53,972] [None] [401] GET https://www.instagram.com/graphql/query/?variables=%7B%22user_id%22%3A%22262927956%22%2C%22include_reel%22%3Atrue%7D&query_hash=ad99dd9d3646cc3c0dda65debcd266a7
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:09:57,101] https://www.instagram.com:443 "GET /graphql/query/?variables=%7B%22user_id%22%3A%22262927956%22%2C%22include_reel%22%3Atrue%7D&query_hash=ad99dd9d3646cc3c0dda65debcd266a7 HTTP/1.1" 401 98
    public.py [ LINE:156] DEBUG    [2023-10-16 23:09:57,102] public_request 401: https://www.instagram.com/graphql/query/?variables=%7B%22user_id%22%3A%22262927956%22%2C%22include_reel%22%3Atrue%7D&query_hash=ad99dd9d3646cc3c0dda65debcd266a7
    public.py [ LINE:160] INFO     [2023-10-16 23:09:57,102] [None] [401] GET https://www.instagram.com/graphql/query/?variables=%7B%22user_id%22%3A%22262927956%22%2C%22include_reel%22%3Atrue%7D&query_hash=ad99dd9d3646cc3c0dda65debcd266a7
   private.py [ LINE:329] INFO     [2023-10-16 23:09:58,102] https://i.instagram.com/api/v1/users/262927956/info/
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:09:58,261] https://i.instagram.com:443 "GET /api/v1/users/262927956/info/ HTTP/1.1" 400 259
   private.py [ LINE:349] DEBUG    [2023-10-16 23:09:58,262] private_request 400: https://i.instagram.com/api/v1/users/262927956/info/ ({"message":"challenge_required","challenge":{"url":"https://i.instagram.com/challenge/?next=/api/v1/users/262927956/info/","api_path":"/challenge/","hide_webview_header":true,"lock":true,"logout":false,"native_flow":true,"flow_render_type":0},"status":"fail"})
   private.py [ LINE:485] INFO     [2023-10-16 23:09:58,262] myprofile [400] GET https://i.instagram.com/api/v1/users/262927956/info/ (269.0.0.18.75, OnePlus 6T Dev)
   private.py [ LINE:329] INFO     [2023-10-16 23:09:59,262] https://i.instagram.com/api/v1/challenge/
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:09:59,738] https://i.instagram.com:443 "GET /api/v1/challenge/ HTTP/1.1" 400 224
   private.py [ LINE:349] DEBUG    [2023-10-16 23:09:59,739] private_request 400: https://i.instagram.com/api/v1/challenge/ ({"message":"challenge_required","challenge":{"url":"https://i.instagram.com/challenge/","api_path":"/challenge/","hide_webview_header":true,"lock":true,"logout":false,"native_flow":true,"flow_render_type":4},"status":"fail"})
   private.py [ LINE:485] INFO     [2023-10-16 23:09:59,739] myprofile [400] GET https://i.instagram.com/api/v1/challenge/ (269.0.0.18.75, OnePlus 6T Dev)
connectionpool.py [ LINE:1048] DEBUG    [2023-10-16 23:10:04,741] Starting new HTTPS connection (1): i.instagram.com:443
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:10:04,919] https://i.instagram.com:443 "GET /challenge/ HTTP/1.1" 200 77
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:10:10,007] https://i.instagram.com:443 "POST /challenge/ HTTP/1.1" 200 90
   private.py [ LINE:329] INFO     [2023-10-16 23:10:16,009] https://i.instagram.com/api/v1/users/262927956/info/
connectionpool.py [ LINE:546] DEBUG    [2023-10-16 23:10:16,164] https://i.instagram.com:443 "GET /api/v1/users/262927956/info/ HTTP/1.1" 400 259
   private.py [ LINE:349] DEBUG    [2023-10-16 23:10:16,165] private_request 400: https://i.instagram.com/api/v1/users/262927956/info/ ({"message":"challenge_required","challenge":{"url":"https://i.instagram.com/challenge/?next=/api/v1/users/262927956/info/","api_path":"/challenge/","hide_webview_header":true,"lock":true,"logout":false,"native_flow":true,"flow_render_type":0},"status":"fail"})
   private.py [ LINE:485] INFO     [2023-10-16 23:10:16,165] myprofile [400] GET https://i.instagram.com/api/v1/users/262927956/info/ (269.0.0.18.75, OnePlus 6T Dev)
base_events.py [ LINE:1753] ERROR    [2023-10-16 23:10:16,165] Task exception was never retrieved
future: <Task finished name='Task-16' coro=<Dispatcher._process_polling_updates() done, defined at C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=ChallengeRequired('challenge_required')>
Traceback (most recent call last):
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\instagrapi\mixins\public.py", line 168, in _send_public_request
    response.raise_for_status()
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22user_id%22%3A%22262927956%22%2C%22include_reel%22%3Atrue%7D&query_hash=ad99dd9d3646cc3c0dda65debcd266a7
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\instagrapi\mixins\private.py", line 360, in _send_private_request
    response.raise_for_status()
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\requests\models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://i.instagram.com/api/v1/users/262927956/info/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\instagrapi\mixins\private.py", line 527, in private_request
    self._send_private_request(endpoint, **kwargs)
  File "C:\code\1_fl\insta_scrapper_bot\venv\lib\site-packages\instagrapi\mixins\private.py", line 393, in _send_private_request
    raise ChallengeRequired(**last_json)
instagrapi.exceptions.ChallengeRequired: challenge_required

During handling of the above exception, another exception occurred:

Screenshots image

How can i solve this?

jtarun4625 commented 9 months ago

Any Update on this bug how to resolve this ?