Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle OAuth from Windows Phone invalid signature
    text
    copied!<p>I've spent the past couple nights on this, and it's driving me mad. Hopefully someone can shed some light on this.</p> <p>I'm trying to write a Windows Phone 7 app to connect to Google. The OAuth routine is really giving me trouble.</p> <p>I've seen quite a few twitter examples, but nothing specific to Google. The code is below - every time I make the request, Google says 'invalid signature.' The base URLs match, everything seems kosher - but it refuses to take it.</p> <pre><code>string baseReqUrl = "https://www.google.com/accounts/OAuthGetRequestToken"; string oauth_consumer_key = "CONSUMER_KEY"; string oauth_consumer_secret = "CONSUMER_SECRET"; string oauth_nonce = OAuthLibrary.OAuth.CreateNonce(); string oauth_signature_method = "HMAC-SHA1"; long oauth_timestamp = OAuthLibrary.OAuth.CreateTimestamp(); //string scope = "https%3A%2F%2Fwww.google.com%2Fanalytics%2Ffeeds%2F"; string scope = "https://www.google.com/analytics/feeds/"; string oauth_callback = "oob"; List&lt;string&gt; sig = new List&lt;string&gt;(); sig.Add(baseReqUrl); sig.Add("oauth_callback=" + oauth_callback); sig.Add("oauth_conusmer_key=" + oauth_consumer_key); sig.Add("oauth_nonce=" + oauth_nonce); sig.Add("oauth_signature_method=" + oauth_signature_method); sig.Add("oauth_timestamp=" + oauth_timestamp.ToString()); sig.Add("scope=" + scope); string baseReq = "GET"; int i = 0; foreach (string s in sig) { if (i == 1) { baseReq = baseReq + "?" + s; } else { baseReq = baseReq + "&amp;" + s; } i++; } HMACSHA1 h = new HMACSHA1(Encoding.UTF8.GetBytes(oauth_consumer_secret)); OAuth.OAuthBase b = new OAuth.OAuthBase(); string normalizedUrl = string.Empty; string normalizedRequestParameters = string.Empty; string sigBase = b.GenerateSignatureBase(new Uri(baseReq.Substring(4)), oauth_consumer_key, null, null, "GET", oauth_timestamp.ToString(), oauth_nonce, "HMAC-SHA1", out normalizedUrl, out normalizedRequestParameters); string signature = b.GenerateSignatureUsingHash(sigBase, h); string reqUrl = normalizedUrl + "?" + normalizedRequestParameters + "&amp;oauth_signature=" + signature; GetUrl(reqUrl); //this line just makes the request </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload