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

Error: challenge_required when trying to follow/login to account #636

Closed Leo-Aqua closed 2 years ago

Leo-Aqua commented 2 years ago

Every time i want to follow/ login to my account I get the error "challenge_required"

My Code:

from instagrapi import Client

cl = Client()
cl.login(MY_ACC, MY_PASS)
Follow = input(str("Who should I follow?: "))
# follow
userid = cl.user_id_from_username(Follow)
cl.user_follow(userid)
print("Done!")
logout()

My output:

Traceback (most recent call last):
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 298, in _send_private_request
    response.raise_for_status()
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 960, 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/friendships/create/37999660686/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 432, in private_request
    self._send_private_request(endpoint, **kwargs)
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 330, in _send_private_request
    raise ChallengeRequired(**last_json)
instagrapi.exceptions.ChallengeRequired: challenge_required

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 298, in _send_private_request
    response.raise_for_status()
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 960, 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/friendships/create/37999660686/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Deggi\Documents\python scripts\ig bot\bot.py", line 8, in <module>
    cl.user_follow(userid)
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\user.py", line 741, in user_follow
    result = self.private_request(f"friendships/create/{user_id}/", data)
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 449, in private_request
    return self._send_private_request(endpoint, **kwargs)
  File "C:\Users\Deggi\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\private.py", line 330, in _send_private_request
    raise ChallengeRequired(**last_json)
instagrapi.exceptions.ChallengeRequired: challenge_required
petersevera commented 2 years ago

Have the same problem. Please, help

adw0rd commented 2 years ago

https://github.com/adw0rd/instagrapi/issues?q=challenge_required https://github.com/adw0rd/instagrapi/discussions?discussions_q=challenge_required