REST API v1
I read previous discussions on 401s, ensure the clock is synced. Really hope you can help with my case.
Sometimes, the streaming API client I wrote would get back 401, trying to connect to Sample or Filter stream. This the example for last failing request (user: @trscs1)
Base string: POST&https%3A%2F%2Fstream.twitter.com%2F1%2Fstatuses%2Ffilter.json&oauth_consumer_key%3DP1i7xB4I2bjlB7Y3E3iOg%26oauth_nonce%3DcYaYcOZNsEe%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1327452066%26oauth_token%3D473447730-A9gisdNgScrSBxqqH7u5x7v4TknpLqUdDNgM5P7s%26oauth_version%3D1.0%26track%3DThailand
Signature string: I9tLP0Ab0+Wzf2k3Lso1VCFdycE=
This is info in the request HTTP headers:
Authorization: OAuth realm="",oauth_signature="I9tLP0Ab0%2BWzf2k3Lso1VCFdycE%3D",oauth_nonce="cYaYcOZNsEe",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1327452066",oauth_consumer_key="P1i7xB4I2bjlB7Y3E3iOg",oauth_token="473447730-A9gisdNgScrSBxqqH7u5x7v4TknpLqUdDNgM5P7s",oauth_version="1.0"
Twitter responded with:
HTTP ERROR: 401
Problem accessing '/1/statuses/filter.json'. Reason:
// multiple white space chars here
Here are the response HTTP headers:
WWW-Authenticate: Basic realm="Firehose"
The 401 is fairly easy to reproduce. In 10 consecutive attempts in a debugging session, I would get 401 multiple times. I understand that Twitter would tolerate a few repeated connection/disconnection. Can I get banned or 401 for this?
I would make sure that your auth header has space characters between the fields -- though that shouldn't necessarily matter.
There are times under system duress that spurious 401s can be returned here, but I don't think that is necessarily what is happening. The OAuth tool you're using tells you whether your signature is correct, but it doesn't tell you whether the entire request you're sending is correct or in agreement with that signature.
What's the exact POST body or querystring you're sending in this request?
Hi @episod, thanks for looking into this! I reformatted the Auth header as suggested, still no dice. As the method used is POST, my POST body is simply "track=Thailand" /wo quotes.
The entire request (another one) that failed:
POST https://stream.twitter.com/1/statuses/filter.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="P1i7xB4I2bjlB7Y3E3iOg", oauth_nonce="dtfrXzcFAdlArulhOJdY", oauth_signature="t71n6W%2Fut0llrUHhJwnqFNkKSn0%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1327512293", oauth_token="473447730-A9gisdNgScrSBxqqH7u5x7v4TknpLqUdDNgM5P7s", oauth_version="1.0"
I restarted my application a few times during debugging. Sometimes I would get 401, the other times everything was good.
Would it be possible that 401 is also sent to an app that did not cleanly close HTTPS connection (from previous session)?
I'm experiencing this very same issue, the application worked for the first 5-10 times I ran it, then it started receiving 401 errors, I don't know if I hit any login limit but I have waited over 8 hours and I can't login again.
I'm pretty sure the request is well designed as it worked before.
Very same thing happen to me. It could work maybe 2 or 3 times but after that or after 30 min of generating the key it gives me this error:
* upload completely sent off: 107 out of 107 bytes
< HTTP/1.1 401 Unauthorized
< WWW-Authenticate: OAuth realm="Firehose"
< Content-Type: text/html
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 1243
< Connection: close
HTTP ERROR: 401
Problem accessing '/1.1/statuses/filter.json'. Reason:
HTTP ERROR: 401
Problem accessing '/1/statuses/sample.json?oauth_body_hash=2jmj7l5rSw0yVb%2FvlWAYkK%2FYBwk%3D&oauth_nonce=46546538&oauth_timestamp=1405530539&oauth_consumer_key=9Y1a4WLKZGmhkM140ZoOR4qoC&oauth_signature_method=HMAC-SHA1&oauth_version=1.0&oauth_token=69577776-5R6rJ2zFJtdByOZLihRJ69LahQupvNifR8cMvuITW&oauth_signature=DaPvGB%2FeoRyPQxY6EMcHDVIV2fE%3D'. Reason:
I am getting above error.I am new to python. Please help
This topic is now closed. New replies are no longer allowed.