Random 401 OAuth authenticate errors with upload_with_media


#1

When using upload_with_media, about 20% of my posts receive a 401 error. The same request can be immediately successful if retried, with only the nonce & timestamp changing. I can’t detect any pattern on why some would work & some not. There are only a few posts per day. Here are the details on one that succeeded on the third attempt. Log times are Sydney time.

Could it be a timestamp issue? I just noticed my computer clock is 6 seconds behind the twitter header returned.

App doing the posting is PaintingsILove. I never get OAuth errors when just posting text status updates.

Attempt 1 - Fail

Signature base - without secret tokens
2011-12-29 11:26:42	POST&https%3A%2F%2Fupload.twitter.com%2F1%2Fstatuses%2Fupdate_with_media.xml&oauth_consumer_key%3D*********************%26oauth_nonce%3D2f932d33f0534ddd9f548e1e3d13d312%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1325118402%26oauth_token%3D***************%26oauth_version%3D1.0

Headers received

2011-12-29 11:26:43	Status: 401 Unauthorized
2011-12-29 11:26:43	X-Runtime: 0.00880
2011-12-29 11:26:43	Content-Length: 161
2011-12-29 11:26:43	Cache-Control: no-cache, max-age=1800
2011-12-29 11:26:43	Content-Type: application/xml; charset=utf-8
2011-12-29 11:26:43	Date: Thu, 29 Dec 2011 00:26:49 GMT
2011-12-29 11:26:43	Set-Cookie: k=211.30.174.119.1325118409298666; path=/; expires=Thu, 05-Jan-12 00:26:49 GMT; domain=.twitter.com,guest_id=v1%3A132511840953447453; domain=.twitter.com; path=/; expires=Sat, 28-Dec-2013 12:26:49 GMT,_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCEVLNoc0AToHaWQiJTk0Yzk3MmUwY2NkNWU4%250AMjRhYTk5ZWUyNjBjNWFhYzVhIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--4cfec3aad018cff02c704eb74c864e00b9b10ec1; domain=.twitter.com; path=/; HttpOnly
2011-12-29 11:26:43	Server: hi
2011-12-29 11:26:43	WWW-Authenticate: OAuth realm="https://upload.twitter.com"
2011-12-29 11:26:43	Expires: Thu, 29 Dec 2011 00:56:49 GMT
2011-12-29 11:26:43	Vary: Accept-Encoding
2011-12-29 11:26:43	Connection: close
2011-12-29 11:26:43	<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/1/statuses/update_with_media.xml</request>
  <error>Could not authenticate with OAuth.</error>
</hash>


Attempt 2 - Fail

Signature base - without secret tokens
2011-12-29 11:26:43	POST&https%3A%2F%2Fupload.twitter.com%2F1%2Fstatuses%2Fupdate_with_media.xml&oauth_consumer_key%3D*********************%26oauth_nonce%3D7f27afff476a4044980b65fa820204ff%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1325118404%26oauth_token%3D***************%26oauth_version%3D1.0

Headers received

2011-12-29 11:26:44	Status: 401 Unauthorized
2011-12-29 11:26:44	X-Runtime: 0.00515
2011-12-29 11:26:44	Content-Length: 161
2011-12-29 11:26:44	Cache-Control: no-cache, max-age=1800
2011-12-29 11:26:44	Content-Type: application/xml; charset=utf-8
2011-12-29 11:26:44	Date: Thu, 29 Dec 2011 00:26:50 GMT
2011-12-29 11:26:44	Set-Cookie: k=211.30.174.119.1325118410464389; path=/; expires=Thu, 05-Jan-12 00:26:50 GMT; domain=.twitter.com,guest_id=v1%3A132511841069811508; domain=.twitter.com; path=/; expires=Sat, 28-Dec-2013 12:26:50 GMT,_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCM5PNoc0AToHaWQiJWQ5ZTIyMWY4MjEwNTRl%250AZWE4MGQzYjNlMWRkOWE3OTkwIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--f3070fb1530fafc15d6b6bf951fb191af30a0b38; domain=.twitter.com; path=/; HttpOnly
2011-12-29 11:26:44	Server: hi
2011-12-29 11:26:44	WWW-Authenticate: OAuth realm="https://upload.twitter.com"
2011-12-29 11:26:44	Expires: Thu, 29 Dec 2011 00:56:50 GMT
2011-12-29 11:26:44	Vary: Accept-Encoding
2011-12-29 11:26:44	Connection: close
2011-12-29 11:26:44	<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/1/statuses/update_with_media.xml</request>
  <error>Could not authenticate with OAuth.</error>
</hash>

Attempt 3 - Success

Signature base - without secret tokens
2011-12-29 11:26:44	POST&https%3A%2F%2Fupload.twitter.com%2F1%2Fstatuses%2Fupdate_with_media.xml&oauth_consumer_key%3D*********************%26oauth_nonce%3D792d9004d0814e22b7d276ebcf983aaa%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1325118405%26oauth_token%3D***************%26oauth_version%3D1.0

2011-12-29 11:26:46	Tweeted: Added a picture "Test" http://goo.gl/Td6ig to PaintingsILove - Result: 152183764544532480