I have an iOS application that sends images to several services, including twitter, and I'm trying to extend this tumblr support. I adapted some open source code for OAuth 1.0a header logic and it works well enough to be successful for twitter + twitpic and for tumblr authentication. However, messages with images in tumblr do not work with status 401 and the string response "Invalid OAuth credentials"
To simplify, my only multi-part sections are message type and image data.
So, my simple POST is http://www.tumblr.com/api/write , the basic signature line (approximately since Ive edited my consumer key and token, and linebreaks are added for readability):
POST&http%3A%2F%2Fwww.tumblr.com%2Fapi%2Fwrite& oauth_consumer_key%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26 oauth_nonce%3D71edd7a1224463a7e1723bb7b568060b4d69deb6%26 oauth_signature_method%3DHMAC-SHA1%26 oauth_timestamp%3D1297678418%26 oauth_token%3Dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx%26 oauth_version%3D1.0%26 type%3Dphoto
my oauth header (again, lines have been added for readability):
Authorization: OAuth realm="http://www.tumblr.com/", oauth_consumer_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1296445530", oauth_nonce="71edd7a1224463a7e1723bb7b568060b4d69deb6", oauth_version="1.0", oauth_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", oauth_signature="fWuli4eO3qVehfdeFzZN%2FDNYpFk%3D"
the only other headers that I add are Content-Type (multipart / form-data) and Content-Length, and the message body is simple:
--my_sorta_unique_boundary_string Content-Disposition: form-data; name="type" photo --my_sorta_unique_boundary_string Content-Disposition: form-data; name="data" Content-Type: image/jpg Content-Transfer-Encoding: binary ... (image data) ... --my_sorta_unique_boundary_string--
Can someone tell me that Ive done something wrong with my base base or auth header, or if there is some trick to make tumblr oauth messages work?
ios iphone oauth tumblr
Pierre houston
source share