c# - Google OAuth from Windows Phone invalid signature -
i've spent past couple nights on this, , it's driving me mad. can shed light on this.
i'm trying write windows phone 7 app connect google. oauth routine giving me trouble.
i've seen quite few twitter examples, nothing specific google. code below - every time make request, google says 'invalid signature.' base urls match, seems kosher - refuses take it.
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<string> sig = new list<string>(); 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 = 0; foreach (string s in sig) { if (i == 1) { basereq = basereq + "?" + s; } else { basereq = basereq + "&" + 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 + "&oauth_signature=" + signature; geturl(requrl); //this line makes request
Comments
Post a Comment