Can anyone from Twitter, or someone who's successfully done it with a consumer library, please lay out the exact format of the HTTP request Twitter expects for an OAuth-signed image upload? By my reading the OAuth spec allows several possibilities, assuming multi-part POST:
POST&http%3A%2F%2Ftwitter.com%2Faccount%2Fupdate_profile_image.xml&
POST /account/update_profile_image.xml HTTP/1.1Content-Type: multipart/form-data; boundary=2e280788-b8f5-4c5e-a05b-9be7ad76fac7User-Agent: DotNetOpenAuth/3.4.0.10010Host: twitter.comCache-Control: no-store,no-cachePragma: no-cacheContent-Length: 20134--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_token"14821025-bq1rTNjyfQrOtb181Alwt0UHPJTffxXDOahZtBrK8--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_consumer_key"ONxVX5b14DpiVGlprq1yA--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_nonce"zvj9dhYY--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_signature_method"HMAC-SHA1--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_signature"IKIkDXQC6JPELXTUv8oU7byaXSU=--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_version"1.0--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="oauth_timestamp"1263176820--2e280788-b8f5-4c5e-a05b-9be7ad76fac7Content-Disposition: form-data; name="image"; filename="thomas jefferson.jpg"Content-Type: image/jpgContent-Transfer-Encoding: binary<beginning of raw binary data>--2e280788-b8f5-4c5e-a05b-9be7ad76fac7
> On Sat, Jan 9, 2010 at 4:59 PM, Andrew Arnott <andrewarn...@gmail.com>wrote:
>
>
>
> > Can anyone from Twitter, or someone who's successfully done it with a
> > consumer library, please lay out the exact format of the HTTP request
> > Twitter expects for an OAuth-signed image upload? By my reading the OAuth
> > spec allows several possibilities, assuming multi-part POST:
>
> > 1. Only the the image (and tile) parameters are in the POST entity.
> > All the OAuth-specific parameters are in the HTTP Authorization header,
> > thereby allowing them to be signed.
> > 2. All the parameters, OAuth ones and image ones, are in the POST
> > entity, leaving nothing by the HTTP method and URL to be signed using the
> > OAuth signature.
> > 3. The OAuth specific parameters appear in the query string of the POST
Yusuke,
Can you please share with us the raw text of your request? I am not
familiar with Java. I am working with C++(.NET)
I know about the basics of oAuth I already working code for posting
tweets with OAuth. I have few doubts with respect to building
signature for multi part requests.
1. What all parameters should be part of the signature base string?
2. Where should the parameters and the signature be placed in the
request stream?
3. How should the file data be sent?
Please help me out.
1. What all parameters should be part of the signature base string?
2. Where should the parameters and the signature be placed in the
request stream?
3. How should the file data be sent?
If you have ever worked with DotNet then please help me.
What I do currently is as follows:
- Set the request type to POST.
- ContentType to "multipart/form-data; boundary=" + boundary
(generated);
- Then I add this to the request stream
L"--"+boundary+L"\r\n"+L"Content-Disposition: form-data;
name=\"image\"; filename=\"test.JPG\" " + L"\r\n"+L"Content-Type:
image/jpg"+L"\r\n\r\n";
- followed by the bytestream of the image.
- Then I continue to add the OAuth params/signature to the stream
All the above are URL encoded.
Twitter responds with a 401 to this request.
What do I have to correct.
After modifications, this is how my request looks like
OAuth signature base:
POST&http%3A%2F%2Ftwitter.com%2Faccount
%2Fupdate_profile_background_image.xml&oauth_consumer_key
%3DgUutCG9HjEOT0N8IxvW9w%26oauth_nonce
%3Dt64bID6gIVtpU6t7m3dsTrTUOhubJizM%26oauth_signature_method%3DHMAC-
SHA1%26oauth_timestamp%3D1263403749%26oauth_token
%3D29191067-7Gl0rjc5KegDdw5p0FJqcBLTmKFF8rCr9Kb3Yt7ZE%26oauth_version
%3D1.0a
I sign this and then add all the parameters to the request stream,
this is how my stream looks like:
oauth_consumer_key=gUutCG9HjEOT0N8IxvW9w&oauth_nonce=t64bID6gIVtpU6t7m3dsTrTUOhubJizM&oauth_signature=TE0lfX3WZwYAr1812GNP8uYJGKc
%3D&oauth_signature_method=HMAC-
SHA1&oauth_timestamp=1263403749&oauth_token=29191067-7Gl0rjc5KegDdw5p0FJqcBLTmKFF8rCr9Kb3Yt7ZE&oauth_version=1.0a&image=
This is followed by the byte stream of the image.
I still get a 401 as response.
Can tell me what I need to change?
Can you please share the raw text of a successful image update request
for oauth?