tags:

views:

8

answers:

0

Hi everyone!

I wrote a library in C# to manage the "OAuth dance" to post new activities on a user buzz public stream. My library seems to work fine:

oauth_signature_method -> HMAC-SHA1

(all the following link are with https)

Scope: www.googleapis.com/auth/buzz

  • www.google.com/accounts/OAuthGetRequestToken OK
  • www.google.com/buzz/api/auth/OAuthAuthorizeToken OK
  • www.google.com/accounts/OAuthGetAccessToken OK -> I get both oauth_token and oauth_token_secret

I also tested oauth_token and oauth_token_secret on oauth_playground with GET https://www.googleapis.com/buzz/v1/activities/@me/@self and it works.

BUT when it comes to execute the GET request in my C# library, I always get the same error:

GData - Authorization - Unknown authorization header

I compared the header of the request from my library with the one from oauth_playground and they are identical:

Accept: / Content-Type: application/atom+xml Authorization: OAuth oauth_version="1.0", oauth_nonce="9216320", oauth_timestamp="1283430867", oauth_consumer_key="www.mysite.com", oauth_token="1%2FZodlNmPP96GT11vYaWA0y6QoqKLqNqZ8bNmxknZZZc", oauth_signature_method="HMAC-SHA1", oauth_signature="Tuu82feKNWa4CxoDUyvtIEVODRA%3D" GData-Version: 2.0

The code I use for the GET request is:

string headAuth = "OAuth oauth_version=\"1.0\", oauth_nonce=\"" + nonce2 + "\", oauth_timestamp=\"" + timeStamp2 + "\", oauth_consumer_key=\"" + consumerKey + "\", oauth_token=

\"" + HttpUtility.UrlEncode(requestTokenUser2) + "\", oauth_signature_method=\"HMAC-SHA1\", oauth_signature=\"" + sig2 + "\"";

HttpWebRequest req1 = (HttpWebRequest)HttpWebRequest.Create(requestUri); req1.Method = "GET";//"POST"; req1.Accept = "/";
req1.ContentType = "application/atom+xml"; req1.Headers.Add("Authorization", headAuth); req1.Headers.Add("GData-Version", "2.0");

HttpWebResponse response1 = (HttpWebResponse)req1.GetResponse();

using (var sr = new StreamReader(response1.GetResponseStream())) {

string test_1 = sr.ReadToEnd(); }

Do you have any idea why it doesn't work with the above request?

Thanks, Stefano