tweepy.error.TweepError: Twitter error response: status code = 401
Closed this issue ยท 5 comments
Traceback (most recent call last):
File "twitter_media_downloader.py", line 36, in <module>
medias = get_medias(auth, user_id, args.retweets, args.image_size, args.since, args.since_id, args.until, args.until_id, args.likes)
File "/root/twitter_media_downloader-master/src/parser.py", line 94, in get_medias
for tweet in tweepy.Cursor(capi, id=user_id, include_rts=include_retweets, include_entities=True, tweet_mode='extended', since_id=since_id, max_id=until_id).items():
File "/usr/local/lib/python2.7/dist-packages/tweepy/cursor.py", line 243, in next
self.current_page = self.page_iterator.next()
File "/usr/local/lib/python2.7/dist-packages/tweepy/cursor.py", line 132, in next
data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kwargs)
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 253, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy/binder.py", line 234, in execute
raise TweepError(error_msg, resp, api_code=api_error_code)
tweepy.error.TweepError: Twitter error response: status code = 401
Similar issue but status code = 400
Check your key and secret key. The README was a little bit confusing. I ended up with 401 too when I tried it first.
Basically, use API token and API secret key instead of the Access token and secret key.
I have tried the API token and API secret key and I keep getting that 401 error :'(
I added access_token
and access_token_secret
to tweepy library and it work.
https://github.com/kittinan/twitter_media_downloader/commit/28ee8abfaa95da7e78f69f239d8b8568d05e0a0b
Indeed, It would seem that a proper access token is required to access protected accounts. Thanks @kittinan. I just pushed a fix for that, sorry for the delay ๐
An invalid key can also cause this issue on public accounts, so I renamed the "consumer token" to "consumer key" to prevent confusion (also because that's the official name now).