question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue
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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Mahiligcommented, Mar 28, 2021

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.

1reaction
Spark-NFcommented, Oct 9, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Twitter API Response Codes & Error Support - Twitter Developer
Different error codes indicate different reasons for an error. The Twitter API attempts to return appropriate HTTP status codes for every request.
Read more >
tweepy and error 401 : r/Python - Reddit
TweepError : Twitter error response: status code = 401 ... I haven't personally used tweepy however if your problem still persists I will...
Read more >
Approval - Twitter API v2 - Twitter Developers
... though when I tried to use tweepy on python to get tweets, I got the error message “TweepError: Twitter error response: status...
Read more >
Frequently Asked Questions — tweepy 4.12.1 documentation
Why am I encountering a 401 Unauthorized error with API or 403 Forbidden error ... See Twitter's API documentation on app permissions for...
Read more >
tweepy.error.TweepError: HTTP Error 401: Unauthorized
'http://twitter.com/oauth/authorize? oauth_token=1Vlq6hb3Hgs0WqgzP0UIdSIXp1bpZXl9PTgryNrI' >>> auth.get_access_token('8643199') <tweepy.oauth.OAuthToken object ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found