Authentication errors on tweets that have a single quote


#1

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:

  1. The token is valid (I verified)
  2. If I repeat the same exact request again, it works. So not an issue with the request formatting.
  3. It never happens if the tweet is just simple text. I can publish 50 tweets and all of them work.
  4. 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.
  5. 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?


POST to /statuses/update.json started hitting error 32 "Could not authenticate you." with no code changes
#2

Bump!

This issue is still causing a lot of problems for my customers. I implemented a retry logic such that when I get a “Could not authenticate you” error I keep retrying for up to 5 times. That helped the situation because most calls do pass through on one of the 4 additional retries. However, twitter needs to fix this because it’s very clunky to have a 30% failure rate on those API calls. Also, occasionally I get 5 errors in a row so the operation fails for the user. In general, it’s causing elevated errors for my users, a lot of complaints, and additional server load for retrying.

Anyone from twitter checking this?


#3

Can you reproduce the problem if you put the authentication information in an Authorization header, and move the status parameter to the POST body?

Both of these are recommended at https://dev.twitter.com/oauth/overview/authorizing-requests.


#4

Isaach, thanks for the suggestion. As we were about to try implement it, we realized that the errors have stopped without any change on our side. It looks like Twitter had fixed the bug on their side.

We’ll go ahead and implement your suggestion anyway since it’s the new recommended way to do it. Thanks again.


#5

Hi Isaach,

This issue is happening again now. We implemented your suggestion about passing the authorization headers, but that doesn’t seem to fix the problem. If the tweet has a single quote, it has a much higher chance of failing with this error than if it doesn’t.

Also, seems there are other noticing this as well now here: