ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.65k stars 1.48k forks source link

ds_user_id, error 400 #1192

Open KadabrahG opened 4 years ago

KadabrahG commented 4 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here:

Python 3.7.2

Error/Debug Log:

No handlers could be found for logger "[instabot_black_book000]" 2019-10-19 12:29:07,368 - INFO - Going to like media with hashtag #dog. Traceback (most recent call last): File "like_hashtags.py", line 26, in bot.like_hashtag(hashtag) File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 687, in like_hashtag return like_hashtag(self, hashtag, amount) File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_like.py", line 235, in like_hashtag medias = self.get_total_hashtag_medias(hashtag, amount) File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot.py", line 535, in get_total_hashtag_medias return get_total_hashtag_medias(self, hashtag, amount, filtration) File "/usr/local/lib/python2.7/dist-packages/instabot/bot/bot_get.py", line 139, in get_total_hashtag_medias medias = self.api.get_total_hashtag_feed(hashtag, amount) File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 1475, in get_total_hashtag_feed self.get_hashtag_feed(hashtag_str, next_max_id) File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 1134, in get_hashtag_feed hashtag=hashtag, max_id=max_id, rank_token=self.rank_token File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 556, in ranktoken return "{}{}".format(self.user_id, self.uuid) File "/usr/local/lib/python2.7/dist-packages/instabot/api/api.py", line 552, in user_id return self.cookie_dict["ds_user_id"] KeyError: 'ds_user_id'

Describe your issue

Relate to issue #1115 #1092 and #860 . Where should the line of code " bot.login(ask_for_code=True) " be added ?

fighterii commented 4 years ago

@KadabrahG I guess you should have a line bot.login() already in your executing file (e.g. in examples/like_hashtags.py its line 23, assuming you are using this file from your traceback.) There you could just add the parameter aks_for_code=True:

bot.login(username=args.u, password=args.p, proxy=args.proxy, ask_for_code=True)

fighterii commented 4 years ago

Maybe we should make ask for code = True default @bruvv @ohld ?

bruvv commented 4 years ago

Yes I wanted to look into this issue this weekend. Perhaps there is a specific error Instagram is returning. If that is the case we can ask the user if they have 2fa enabled and ask for code ?

4godev commented 4 years ago

Maybe we should make ask for code = True default @bruvv @ohld ?

Hello, has this situation been updated? I'm having the same problem, instagram asks for login confirmation and I can't access the account.

2020-02-03 13:47:33,997 - DEBUG - Responsecode indicates error; response content: b'{"message": "challenge_required", "challenge": {"url": "https://i.instagram.com/challenge/6525713726/yCJm9h2FwX/", "api_path": "/challenge/6525713726/yCJm9h2FwX/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true}, "status": "fail", "error_type": "checkpoint_challenge_required"}' 2020-02-03 13:47:34,000 - ERROR - Request returns 400 error! 2020-02-03 13:47:34,001 - INFO - Instagram's error message: challenge_required 2020-02-03 13:47:34,003 - INFO - Error type: checkpoint_challenge_required 2020-02-03 13:47:34,004 - INFO - Checkpoint challenge required...

le0a commented 4 years ago

Same here, 2FA disabled, the issue is happening on master and development. Cleared the .json, changed the password, same issue. I have tried another account, no problem whatsoever.

Carnivalio commented 4 years ago

I want to share/update my experience about this problem, first, here's the error message

Traceback (most recent call last): File "C:\Wrapper.py", line 102, in <module> execute_upload(db_path, export_path, ex_caption_path, leading_name, config_path, cookie_path, log_path) File "C:\Wrapper.py", line 52, in execute_upload insta_bot.login(ask_for_code=True, use_cookie=True, cookie_fname=cookie_path) File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\bot\bot.py", line 443, in login if self.api.login(**args) is False: File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api.py", line 266, in login self.pre_login_flow() File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api.py", line 182, in pre_login_flow return pre_login_flow(self) File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api_login.py", line 107, in pre_login_flow self.sync_device_features() File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api.py", line 155, in sync_device_features return sync_device_features(self, login) File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api_login.py", line 23, in sync_device_features data["_uid"] = self.user_id File "C:\Users\<UserDir>\AppData\Local\Programs\Python\Python37\lib\site-packages\instabot\api\api.py", line 617, in user_id return self.cookie_dict["ds_user_id"] KeyError: 'ds_user_id'

After trying to figure out what is happening when the script is trying to log in, I found out that the session on the api (this instabot) only have 3 keys

{'csrftoken': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'mid': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'rur': 'xxx'}

as I don't understand (yet) on how all this login flow works, that's just how far I can snoop in, hope this will help the maintainer find a solution.

INFO: I've tried with 3 clean account to no avail, all have the same error, and if you try it too often, you will get HTTP 429

EDIT: I have no cookie files and any database files related to instabot whatsoever

bruvv commented 4 years ago

@Carnivalio your error is not related to this issue but related to this: https://github.com/instagrambot/instabot/issues/1317

Carnivalio commented 4 years ago

@bruvv oh! sorry then, I'll move it there, thanks for the heads up, though I thought it's related because of the 'ds_user_id'

EDIT: @bruvv mentioned it on #1317, so I'll just leave it be