Aha, the script works!
./ton_upload --mode upload --bucket ta_partner --file test_file -t
Yields:
<- "POST https://ton.twitter.com/1.1/ton/bucket/ta_partner HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: OAuth gem v0.4.7\r\nContent-Type: text/plain\r\nContent-Length: 46\r\nX-Ton-Expires: Sun, 19 Apr 2015 19:07:27 GMT\r\nAuthorization: OAuth oauth_body_hash=\"XXXXX\", oauth_consumer_key=\"XXXXX\", oauth_nonce=\"XXXXX\", oauth_signature=\"XXXXX\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1428606447\", oauth_token=\"XXXXX\", oauth_version=\"1.0\"\r\nConnection: close\r\nHost: ton.twitter.com\r\n\r\n"
<- “66212d979ad3c690773c18ba12a4d608b79af6625e8c\n\n”
-> “HTTP/1.1 201 Created\r\n”
…
Now it’s a matter of imitating enough of this so it will work with our app…
Edit: The missing piece seemed to be “X-Ton-Expires” in the header. Here’s Python code (using requests-oauthlib) that uploaded successfully to /ton giving a 201 status:
res = requests.post(
TON_URL + '/ton/bucket/ta_partner',
data=data,
headers={
'Content-Type': 'text/plain',
'X-Ton-Expires': 'Sun, 19 Apr 2015 19:57:30 GMT',
},
auth=requests_oauthlib.OAuth1(
settings.TWITTER_APP_KEY, settings.TWITTER_APP_SECRET, creds['accessKey'], creds['accessSecret'])
)