-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream.statuses.filter returns Error 401 Unauthorized suddenly #285
Comments
This is happening to me as well, I'm using 1.17.1 with the same error. Can somebody help?
|
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. |
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! |
keeping this one open as documentation for further people |
Please help, I faced this problem; \n\n\n<title>Error 401 Unauthorized</title>HTTP ERROR: 401Problem 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: Unauthorized |
Hi @sunny074u, looking at the keys in your url, it looks like you're using |
Well thanks, I had a 20min time drift & was going mad :) |
As a reminder, when this happens, a typical resolution on linux machines is:
|
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? |
Hasn't your account/API keyset been suspended by twitter maybe? These are the main two possible reasons I experienced |
Hi @RouxRC >>> t = TwitterStream(auth=OAuth("XX", "XX", "XX", "XX"))
>>> t
<twitter.stream.TwitterStream object at 0x7f888f6782d0>
>>> t.statuses.sample()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "twitter/api.py", line 334, in __call__
return self._handle_response(req, uri, arg_data, _timeout)
File "twitter/stream.py", line 264, in _handle_response
_timeout or timeout, heartbeat_timeout)
File "twitter/stream.py", line 213, in handle_stream_response
raise TwitterHTTPError(e, uri, 'json', arg_data)
twitter.api.TwitterHTTPError: Twitter sent status 401 for URL: 1.1/statuses/sample.json using parameters: (oauth_consumer_key=XX&oauth_nonce=XX&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1593696259&oauth_token=XX&oauth_version=1.0&oauth_signature=pCmGt%2BrmWppCCCewrpGezi0Acb8%3D)
details: <html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n<title>Error 401 Unauthorized</title>
</head>
<body>
<h2>HTTP ERROR: 401</h2>
<p>Problem accessing '/1.1/statuses/sample.json?oauth_consumer_key=XX&oauth_nonce=XX&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1593696259&oauth_token=RRVD4z4jcFLCfaORJpVGmCFTW&oauth_version=1.0&oauth_signature=pCmGt%2BrmWppCCCewrpGezi0Acb8%3D'. Reason:
<pre> Unauthorized</pre>
</body>
</html> |
Hi, |
@RouxRC you're right. >>> t = Twitter(auth=OAuth('xx-wa4vYbh7sFg7dTlUZ4dq7fUGjgGhwz', 'xx', 'xx', 'xx'))
>>> t.statuses.sample()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "twitter/api.py", line 334, in __call__
return self._handle_response(req, uri, arg_data, _timeout)
File "twitter/api.py", line 367, in _handle_response
raise TwitterHTTPError(e, uri, self.format, arg_data)
twitter.api.TwitterHTTPError: Twitter sent status 404 for URL: 1.1/statuses/sample.json using parameters: (oauth_consumer_key=xx&oauth_nonce=114329492091994170&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1594070658&oauth_token=xx-wa4vYbh7sFg7dTlUZ4dq7fUGjgGhwz&oauth_version=1.0&oauth_signature=Jhkm69Avymum2taLySZ%2BxNaEFU4%3D)
details: {u'errors': [{u'message': u'Sorry, that page does not exist', u'code': 34}]}
>>> t.search.tweets(q='test')
{u'search_metadata': {u'count': 15, u'completed_in': 0.059, u'max_id_str': u'1280251196398329857', u'since_id_str': u'0', u'next_results': u'?max_id=1280251182687158272&q=test&include_entities=1', u'refresh_url': u'?since_id=1280251196398329857&q=test&include_entities=1', u'since_id': 0, u'query': u'test', u'max_id': 1280251196398329857}, u'statuses': [{u'contributors': None, u'truncated': True, u'text': u'@Will_BrysonMVCS @Sooner_Source And they are counting tests as positive if you have an appointment then leave befor\u2026 https://t.co/qkJGFakdR8', u'is_quote_status': False, u'in_reply_to_status_id': 1280248041434492928, u'id': 1280251196398329857, u'favorite_count': 0, u'entities': {u'symbols': [], u'user_mentions': [{u'id': 778229275015118848, u'indices': [0, 16], u'id_str': u'778229275015118848', u'screen_name': u'Will_BrysonMVCS', u'name': u'Coach Bryson'}, {u'id': 278899813, u'indices': [17, 31], u'id_str': u'278899813', u'screen_name': u'Sooner_Source', u'name': u'SoonerSource'}], u'hashtags': [], u'urls': [{u'url': u'https://t.co/qkJGFakdR8', u'indices': [117, 140], u'expanded_url': u'https://twitter.com/i/web/status/1280251196398329857', u'display_url': u'twitter.com/i/web/status/1\u2026'}]}, u'retweeted': False, u'coordinates': None, u'source': u'<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone</a>', u'in_reply_to_screen_name': u'Will_BrysonMVCS', u'in_reply_to_user_id': 778229275015118848, u'retweet_count': 0, u'id_str': u'1280251196398329857', u'favorited': False, u'user': {u'follow_request_sent': False, u'has_extended_profile': True, u'profile_use_background_image': True, u'default_profile_image': False, u'id': 904837484953165824, u'profile_background_image_url_https': None, u'verified': False, u'translator_type': u'none', u'profile_text_color': u'333333', u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/1267662209557151747/QQ3YXw_-_normal.jpg', u'profile_sidebar_fill_color': u'DDEEF6', u'entities': {u'description': {u'urls': []}}, u'followers_count': 1200, u'profile_sidebar_border_color': u'C0DEED', u'id_str': u'904837484953165824', u'profile_background_color': u'F5F8FA', u'listed_count': 1, u'is_translation_enabled': False, u'utc_offset': None, u'statuses_count': 15284, u'description': u'Basketball Enthusiast \u2022 Christ Follower \u2022 @tristentamera significant other \u2764\ufe0f', u'friends_count': 1841, u'location': u'Mustang, OK', u'profile_link_color': u'1DA1F2', u'profile_image_url': u'http://pbs.twimg.com/profile_images/1267662209557151747/QQ3YXw_-_normal.jpg', u'following': False, u'geo_enabled': True, u'profile_banner_url': u'https://pbs.twimg.com/profile_banners/904837484953165824/1589757129', u'profile_background_image_url': None, u'screen_name': u'CodyJohnsonBB', u'lang': None, u'profile_background_tile': False, u'favourites_count': 19320, u'name': u'Coach Johnson', u'notifications': False, u'url': None, u'created_at': u'Mon Sep 04 22:44:02 +0000 2017', u'contributors_enabled': False, u'time_zone': None, u'protected': False, u'default_profile': True, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': u'778229275015118848', u'lang': u'en', u'created_at': u'Mon Jul 06 21:24:05 +0000 2020', u'in_reply_to_status_id_str': u'1280248041434492928', u'place': None, u'metadata': {u'iso_language_code': u'en', u'result_type': u'recent'}}]} I trimmed the json output for better readability, but the command succeeds. |
Ha all right I think I know: you're not using the proper class for Stream routes, you should use |
PS : and it's normal that |
Indeed, works like a charm now. Thanks @RouxRC ! |
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.
I am using 1.14.3. Any body help? Thanks!
The text was updated successfully, but these errors were encountered: