Open johackim opened 5 years ago
Describe the bug
I excute same command every day. Since today, Instagram seems to require an verification. Instapy-cli display a "challenge_required" message.
To Reproduce
instapy -u myuser -p mypassword -f https://i.imgur.com/EaWUsOs.jpg -t "Comment se faire des amis"
Expected behavior
Sending a working instagram post.
Logs If there are any errors or exceptions, add the logs to help explain your problem.
ClientError checkpoint_challenge_required (Code: 400, Response: {"message": "challenge_required", "challenge": {"url": "https://i.instagram.com/challenge/13063477860/GhKeUCVT2D/", "api_path": "/challenge/13063477860/GhKeUCVT2D/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true}, "status": "fail", "error_type": "checkpoint_challenge_required"})
Env (please complete the following information):
- OS: archlinux
- Python: 3.7.3
- instapy-cli Version: 0.0.12
Restart your wifi. Welcome.
Restart wifi did not work for me.
Restart wifi did not work for me.
Instagram will block both your ipaddress and account for suspicious acitivities. like: Repetitive actions, Multiple Logins, and login from different locations(states,countries frequently) and PCs. perhaps Instagram has blocked your IP address and account temporarily. Change your IP address then run it again. Use a VPN or anything like a virtual server that can change your IP address. But run it wisely this time. Try to access another account from another computer. Hope It will work.
You are correct. Changing the ip does work. I changed to posting through my iphone hotspot and the post worked! Super great.
Wish there was a little more documentation on the cookies. I think it automatically uses the cookie if it has it. But is has to be renamed correctly. Should the cookie be: ie: BOBSMITH_id.json?
I just ran into this as well. Tried changing the IP address by tethering the laptop to my phone, and got the same error. Will try again tomorrow. Otherwise, should we assume that our Instagram account has been permanently blocked from using this upload method?
Also, just to respond to @potter-potter: We have been logging in every time we upload a video (about every weekday). It isn't obvious to me if/how the locally stored cookie can be created or used from the command-line interface.
You are correct. Changing the ip does work. I changed to posting through my iphone hotspot and the post worked! Super great.
Wish there was a little more documentation on the cookies. I think it automatically uses the cookie if it has it. But is has to be renamed correctly. Should the cookie be: ie: BOBSMITH_id.json?
Correct. USERNAME_ig.json
Tried it again, and got a different error message:
ClientError URLError <urlopen error [Errno 8] nodename nor servname provided, or not known> (Code: 0, Response: )
Did a little googling, and it seems these errors are being thrown by the underlying instagram_private_api, as suggested by this issue. The diagnosis is that Instagram these errors indicate that Instagram has flagged an account as spammy.
In instagram_private_api's README includes as a note recommending that users avoid excessive logins by caching the auth cookie.
Caching the auth cookie isn't instapy-cli's default behavior, correct? Is it an invokable option via the command line? If not, would you accept a pull request wherein we added this feature?
@gordonje I'm not using command line. But I have had good luck with the cookie.
It needs to be named exactly as the instagram username with _ig.json. Not in capital letters as I first thought. So bobscookies2022_ig.json if the user is bobscookies2022. I used the cookie writer example to create the file and then renamed it correctly. It even works if I generate it on one computer (or phone hotspot) and use on a different computer (ip address)
As far as using it in my python script, as long as the file is in the same directory as the script, it will find the cookie file:
with client(username, password) as cli:
# get string cookies. Not sure if this is necessary.
cookies = cli.get_cookie()
cli.upload(image_path, full_caption)
@potter-potter Thanks for pointing that out.
Full disclosure: I discovered this library while researching options for work colleague who isn't a Pythonista or a developer of any sort. I taught him how to open his terminal app and type in the command for uploading his daily videos to his show's Instagram account. Accept for this blocking issue that came up, it's been working really well for him. So I'm eager for a resolution that allows him to continue using the command line.
Another update: After my colleague logged out of his Instagram account on his phone, logged back in, and waited for a couple of days, he is once again able to upload videos from the command line.
Still interested in whether or not caching the auth cookie is/could be added to the CLI.
Hey guys, currently playing around with this. If i execute the example of creating the cookie (https://github.com/instagrambot/instapy-cli/blob/master/examples/login-cookie-write-file.py) with my username and pw i dont seem to be creating a cookie file. it should be in the same local directory or not?
The documentation is confusing on this topic as the example is sadly not commented. Lets say my username is "FruechteBini" and my passwort is "orange123", if i execute the script like this:
from instapy_cli import client
username = 'FruechteBini'
password = 'orange123'
cookie_file = 'FruechteBini_ig.json' # default: `USERNAME_ig.json`
with client(username, password, cookie_file=cookie_file, write_cookie_file=True) as cli:
# get string cookies
cookies = cli.get_cookie()
print(type(cookies)) # == str
print(cookies)
# do stuffs with cli
ig = cli.api()
me = ig.current_user()
print(me)
i instantly get the [IG] not found cookie/cookie_file >> login as default
message. Shouldnt this script create the cookie? I am confused, any hint in the right direction is appreciated!
EDIT: i am building a IG-photobox for a party - pressing a button will automatically upload the picture to instagram story. Everything is working besides instagram detecting suspicious behaviour for logging in everytime I call instapy-cli..
Ok, i got it to work. The problem was that once you are blocked (from IG, the IP or whatever) you cant create the cookie file anymore. This instapy_cli is great work but i still think the documentation on the cookie stuff should be a bit more detailed. A quick heads-up that you get banned if you dont use cookies and want to do frequent stuff for example. Nevertheless thanks for the feature, cheers!
Uff, i actually do have trouble with this aswell - my cookie does not get generated if i use the generation script and it always says:
ClientError checkpoint_challenge_required (Code: 400, Response: {"message": "challenge_required", "challenge": {"url": "https://i.instagram.com/challenge/integerValues/String/", "api_path": "/challenge/integerValues/String/", "hide_webview_header": true, "lock": true, "logout": false, "native_flow": true}, "status": "fail", "error_type": "checkpoint_challenge_required"})
so i will wait a bit as recommended here and once i get it to work i call back
@Grizzaka - yeah! I think you can A) just wait until instagram unblocks you or B) as others said (haven't tried it my self) get a new IP (eg. restart router) - could do the trick aswell. And dont try to upload a story/post before generating the cookie - i assume this attempt will block you again.
@FruechteBini I switched to my personal account and it worked like a charm - without any problems i was able to upload a photo and an entire story (even without cookie) - so yea it was the other account who made some trouble.
i waited a few days now and even the other account works now. +1
I'm still having the same problem. I have tried several different accounts and IP combinations. It will not write the cookie file. Do I need to log off on the iPhone?
Edit: Changed location and it's working now.
i think it seems like ig detect a bot and ban the use of this api. What do you think?
Edit: Changed location and it's working now.
What do you mean by changing the location ? the location of your vpn ?
Edit: Changed location and it's working now.
Could you please provide more details about what is means this? Did you changed the IP address? Thanks
I'm failing on this same challenge ClientError checkpoint_challenge_required (Code: 400, Response
...
Does anyone have an example of what a working USERNAME_ig.json
looks like?
Can I copy a cookie from my browser after successfully logging in?
Describe the bug
I excute same command every day. Since today, Instagram seems to require an verification. Instapy-cli display a "challenge_required" message.
To Reproduce
Expected behavior
Sending a working instagram post.
Logs If there are any errors or exceptions, add the logs to help explain your problem.
Env (please complete the following information):