I have a media API and I’m attempting to allow users of third party applications to tweet video via my API, so I’m implementing Oauth Echo. I am able to complete the first step, verifying the user’s credentials; however, when I go to initialize the upload I get a “Could not authenticate you” error. In the chunked media upload docs, I noticed this section, but it’s unclear to me how this applies to performing chunked media upload via Oauth Echo:
“Because the method uses multipart POST, OAuth is handled a little differently. POST or query string parameters are not used when calculating an OAuth signature basestring or signature. Only the oauth_* parameters are used.”
Here’s my trace:
opening connection to upload.twitter.com:443…
opened
starting SSL for upload.twitter.com:443…
SSL established
<- “POST /1.1/media/upload.json?command=INIT&media_type=video%2Fmp4&total_bytes=2000 HTTP/1.1\r\nAuthorization: OAuth oauth_consumer_key=“XXXXXXXXXXXXXXXXX”, oauth_nonce=“XXXXXXXXXXXXXXXXX”, oauth_signature=“XXXXXXXXXXXXXXXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_timestamp=“1457492349”, oauth_token=“XXXXXXXXXXXXXXXXX”, oauth_version=“1.0”\r\nConnection: close\r\nHost: upload.twitter.com\r\nContent-Length: 0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n”
<- “”
-> “HTTP/1.1 401 Authorization Required\r\n”
-> “connection: close\r\n”
-> “content-length: 64\r\n”
-> “content-type: application/json; charset=utf-8\r\n”
-> “date: Wed, 09 Mar 2016 03:10:23 GMT\r\n”
-> “server: tsa_a\r\n”
-> “set-cookie: guest_id=v1%3A145749302339262531; Domain=.twitter.com; Path=/; Expires=Fri, 09-Mar-2018 03:10:23 UTC\r\n”
-> “strict-transport-security: max-age=631138519\r\n”
-> “vary: Origin\r\n”
-> “x-connection-hash: 6a4b3c223cca493550d30c3fed750df1\r\n”
-> “x-frame-options: SAMEORIGIN\r\n”
-> “x-response-time: 7\r\n”
-> “x-xss-protection: 1; mode=block\r\n”
-> "\r\n"
reading 64 bytes…
-> “”
-> "{“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}"
read 64 bytes
Conn close
=> #<HTTParty::Response:0x7ffec2e900e8 parsed_response={“errors”=>[{“code”=>32, “message”=>“Could not authenticate you.”}]}, @response=#<Net::HTTPUnauthorized 401 Authorization Required readbody=true>, @headers={“connection”=>[“close”], “content-length”=>[“64”], “content-type”=>[“application/json; charset=utf-8”], “date”=>[“Wed, 09 Mar 2016 03:10:23 GMT”], “server”=>[“tsa_a”], “set-cookie”=>[“guest_id=v1%3A145749302339262531; Domain=.twitter.com; Path=/; Expires=Fri, 09-Mar-2018 03:10:23 UTC”], “strict-transport-security”=>[“max-age=631138519”], “vary”=>[“Origin”], “x-connection-hash”=>[“6a4b3c223cca493550d30c3fed750df1”], “x-frame-options”=>[“SAMEORIGIN”], “x-response-time”=>[“7”], “x-xss-protection”=>[“1; mode=block”]}>