Last Updated: February 25, 2016
·
957
· scott2b

Arbitrary 401 Errors with the Twitter API

Pulling your hair out with the Twitter API getting 401 errors that seem arbitrary and are inconsistent from server to server? I was getting this particularly with the streaming API.

First of all, check your credentials. Twitter exposes a verify_credentials method for checking that you can get a valid authenticated connection. That is documented here: https://dev.twitter.com/docs/api/1/get/account/verify_credentials.

Getting a 200 for verify_credentials but the streaming API is still kicking you with a 401? Check your server time!

We had an AWS instance that was off by 10 minutes (10 minutes!). Kicked the time and all is now well. Healthy connection to the streaming API.