You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
I have been using this great api for tracking some twitter keywords for a while, but suddenly, since Feb 24 around 13:00 I got "Error 401 Unauthorized" error.
This looks to me like a badly documented issue regarding OAuth and timestamps: if that's the case, basically your server is slighty shifted from the actual time and when Twitter gets your OAuth timestamped queries they're considered outdated. This typically happens sometimes after leapSecond changes if the time is not properly fixed on the server.
So can you try and update the time on your machine and see whether that solves it?
Otherwise it might be a simple auth issue, maybe try to regen and change your tokens/secret on dev.twitter.com
Problem accessing '/1/statuses/sample.json?oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D&oauth_nonce=49357639&oauth_timestamp=1476141985&oauth_consumer_key=%3CkahjO7UXvguegErgJZBNLHmO3%3E&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=%3C340989397-wnPAEy0p0L2VvyYAYOR75ATdnKNL5eX6QFg3RhbE%3E&oauth_signature=4TU60zYSGpEZqAYaAEJlEs0F47Y%3D'. Reason:
Hi @RouxRC
Yes, I double checked. I used another api (tweepy) to test tweeting and it actually works so the keys must be valid. Actually even the basic operations don't work (e.g. home_timeline returns 404). I'll check again if there's something wrong but for the record here's the log :
Hi,
All examples output you've shown are 401 on stream routes, can you show other routes with the same auth?
For instance what does t.search.tweets(q="test") return?
Activity
minuscorp commentedon Jul 31, 2015
This is happening to me as well, I'm using 1.17.1 with the same error.
Can somebody help?
RouxRC commentedon Jul 31, 2015
This looks to me like a badly documented issue regarding OAuth and timestamps: if that's the case, basically your server is slighty shifted from the actual time and when Twitter gets your OAuth timestamped queries they're considered outdated. This typically happens sometimes after leapSecond changes if the time is not properly fixed on the server.
So can you try and update the time on your machine and see whether that solves it?
Otherwise it might be a simple auth issue, maybe try to regen and change your tokens/secret on dev.twitter.com
minuscorp commentedon Jul 31, 2015
Actually that was true.
My server has (don't know why) a time drift, I synced it again with an NTP Server and it worked again.
Thank you so much!
RouxRC commentedon Jan 4, 2016
keeping this one open as documentation for further people
sunny074u commentedon Oct 11, 2016
Please help, I faced this problem;
\n\n\n<title>Error 401 Unauthorized</title>HTTP ERROR: 401
Problem accessing '/1/statuses/sample.json?oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D&oauth_nonce=49357639&oauth_timestamp=1476141985&oauth_consumer_key=%3CkahjO7UXvguegErgJZBNLHmO3%3E&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=%3C340989397-wnPAEy0p0L2VvyYAYOR75ATdnKNL5eX6QFg3RhbE%3E&oauth_signature=4TU60zYSGpEZqAYaAEJlEs0F47Y%3D'. Reason:
RouxRC commentedon Oct 23, 2016
Hi @sunny074u, looking at the keys in your url, it looks like you're using
<(%3c)>(%3e) symbols around your keys in your oauth setting.nedd-bastien commentedon Jan 4, 2017
Well thanks, I had a 20min time drift & was going mad :)
(aptitude install ntp, on debian, did the trick)
RouxRC commentedon Jun 28, 2017
As a reminder, when this happens, a typical resolution on linux machines is:
n-eq commentedon Jul 2, 2020
Hi @RouxRC !
I am running into the same issue and it doesn't seem it's a time drift problem (I executed the ntp script but it didn't change anything.)
Any updates?
RouxRC commentedon Jul 2, 2020
Hasn't your account/API keyset been suspended by twitter maybe? These are the main two possible reasons I experienced
n-eq commentedon Jul 2, 2020
Hi @RouxRC
Yes, I double checked. I used another api (tweepy) to test tweeting and it actually works so the keys must be valid. Actually even the basic operations don't work (e.g. home_timeline returns 404). I'll check again if there's something wrong but for the record here's the log :
RouxRC commentedon Jul 6, 2020
Hi,
All examples output you've shown are 401 on stream routes, can you show other routes with the same auth?
For instance what does
t.search.tweets(q="test")return?n-eq commentedon Jul 6, 2020
@RouxRC you're right.
Here's the output of the command you requested.
I trimmed the json output for better readability, but the command succeeds.
RouxRC commentedon Jul 6, 2020
Ha all right I think I know: you're not using the proper class for Stream routes, you should use
t=TwitterStream(auth=OAuth(...))insteadRouxRC commentedon Jul 6, 2020
PS : and it's normal that
home_timelinereturns a 404, it was shut down by Twitter a few months agon-eq commentedon Jul 6, 2020
Indeed, works like a charm now. Thanks @RouxRC !
hugovk commentedon Feb 7, 2025
Thanks for the report, however we're no longer maintaining this project and will be archiving it.
The existing releases and code will remain available in their current state.