Spark-NF / twitter_media_downloader

Twitter media downloader.
Apache License 2.0
293 stars 52 forks source link

tweepy.error.TweepError: Twitter error response: status code = 401 #21

Closed MarioVilas closed 2 years ago

MarioVilas commented 3 years ago
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
MetalMake64 commented 3 years ago

Similar issue but status code = 400

Mahilig commented 3 years ago

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.

nikos3194 commented 3 years ago

I have tried the API token and API secret key and I keep getting that 401 error :'(

kittinan commented 2 years ago

@nikos3194

I added access_token and access_token_secret to tweepy library and it work.

https://github.com/kittinan/twitter_media_downloader/commit/28ee8abfaa95da7e78f69f239d8b8568d05e0a0b

Spark-NF commented 2 years ago

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).