Frage

I've been working with Python Twitter Tools and haven't had any problems authenticating with the REST API through this library.

But when I try to authenticate with the Streaming API, I get nothing but 401 HTTP Unauthorized errors.

Similar to the website my code is as follows:

stream = TwitterStream(
auth=OAuth(OAUTH_TOKEN, OAUTH_SECRET,
           CONSUMER_KEY, CONSUMER_SECRET)
)

stream.statuses.sample()

I've tried:

  1. Double checking my Tokens/Keys -- I know they're right because I can authenticate using the same tokens and keys through the same library to the REST API.

  2. Double checking my permissions level -- I even purposely changed it to Read, Write & Direct Messages, still doesn't work.

  3. Also, I looked on the Twitter Dev website and it says that I only need OAuth in order to authenticate with the Streaming API, so I don't think its a problem with that either. I only need access to the public stream, nothing higher than that.

  4. Checked that I have the latest version of the library -- I do.

Any suggestions would be helpful! :)

War es hilfreich?

Lösung

Turns out it was an OAuth problem, my clock on my computer was more than +/-5 minutes than the Twitter server's and so for authorization reasons, I kept getting a HTTP 401 Error.

Fix: Change your computer's internal clock to match that of Twitter's or change your OAuth timestamp calls.

Issue found in the python twitter tool's repository issues

Also, for your reference, OAuth Troubleshooting -- about 8th point down talks about timestamps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top