This is a very odd error that started happening a few days ago. I post a tweet as usual (API v1.1) and it works most of the time, but occasionally it fails with:
{"errors":[{"message":"Could not authenticate you","code":32}]}
However:
- The token is valid (I verified)
- If I repeat the same exact request again, it works. So not an issue with the request formatting.
- It never happens if the tweet is just simple text. I can publish 50 tweets and all of them work.
- But if the post has a single quote (’) in it, then the publishing fails 30% of the time. Not all the time (which might indicate an encoding issue), but only 1 out 3 tweets fail.
- The issue only happens when I run my testing code on Google App Engine (where I host my app). If I run the same code locally it works always, even if the tweets have single quotes.
Here is a sample request and response:
Request
POST https://api.twitter.com/1.1/statuses/update.json?status=Test%20staging%20single%20quote%20%27%20Test22&oauth_version=1.0&in_reply_to_status_id=None&oauth_token=41002916-XXXX&oauth_nonce=55962323&oauth_timestamp=1418789426&oauth_signature=zEBW3q9PofTnlNLy9E6ydh%2BrRwI%3D&oauth_consumer_key=XXXXX&oauth_signature_method=HMAC-SHA1
Response
{"errors":[{"message":"Could not authenticate you","code":32}]}
Has anyone encountered such problem?