Note that there are some explanatory texts on larger screens.

plurals
  1. POOAuth with Google data API for .NET returning HTTP 400: Bad Request
    primarykey
    data
    text
    <p>I am trying to get OAuth working with the .NET library for Google Data API. Unfortunately, whenever I call GetUnauthorizedRequestToken, I get a 400 Bad Response error. Here is my code...</p> <pre><code>OAuthParameters parameters = new OAuthParameters() { ConsumerKey = DOMAIN_NAME, ConsumerSecret = SECRET_KEY, Scope = "https://docs.google.com/feeds/", Callback = Request.RawUrl, SignatureMethod = "HMAC-SHA1" }; OAuthUtil.GetUnauthorizedRequestToken(parameters); </code></pre> <p>As far as I know I am correctly following the instructions here: <a href="http://code.google.com/apis/gdata/docs/auth/oauth.html" rel="nofollow">http://code.google.com/apis/gdata/docs/auth/oauth.html</a></p> <p>Any help with this problem would be much appreciated!</p> <h3>EDIT: 9/10/2011 11:56 PM PST</h3> <p>First of all, thank you so much for the comments!</p> <p>So I've fiddled around a bit and got the Unauthorized Request Token working, but OAuth is still not really working... here is a more complete code dump :-\</p> <pre><code>string token = Request["oauth_token"]; if (!String.IsNullOrEmpty(token)) { OAuthParameters tParams = new OAuthParameters() { ConsumerKey = DOMAIN_NAME, ConsumerSecret = SECRET_KEY, Scope = S_SCOPE, Callback = S_CALLBACK, SignatureMethod = "HMAC-SHA1" }; tParams.Verifier = Request["oauth_verifier"]; tParams.Token = token; try { // http://code.google.com/apis/gdata/docs/auth/oauth.html // 1. Extract token from the callback URL //OAuthUtil.UpdateOAuthParametersFromCallback(Request.Url.Query, parameters); // 2. Upgrade to an access token OAuthUtil.GetAccessToken(tParams); string accessToken = tParams.Token; string accessTokenSecret = tParams.TokenSecret; Session["sp"] = tParams; // don't worry, we don't even get here yet return RedirectToAction("List"); } catch (System.Net.WebException ex) { // print out tons of stuff (removed for sanity) } //... and start over again } try { OAuthParameters parameters = new OAuthParameters() { ConsumerKey = DOMAIN_NAME, ConsumerSecret = SECRET_KEY, Scope = S_SCOPE, Callback = S_CALLBACK, SignatureMethod = "HMAC-SHA1" }; OAuthUtil.GetUnauthorizedRequestToken(parameters); string approvalPageUrl = OAuthUtil.CreateUserAuthorizationUrl(parameters); ViewBag.AuthUrl = approvalPageUrl; } catch (System.Net.WebException ex) { // print out more stuff } </code></pre> <p>and this is the error I am seeing (slightly modified to remove sensitive data, however I left all the symbols as-is in case someone thinks this is an encoding error):</p> <pre><code>X-Content-Type-Options = nosniff X-XSS-Protection = 1; mode=block Content-Length = 386 Cache-Control = private, max-age=0 Content-Type = text/plain; charset=UTF-8 Date = Sun, 11 Sep 2011 06:53:26 GMT Expires = Sun, 11 Sep 2011 06:53:26 GMT Server = GSE /accounts/OAuthGetAccessToken signature_invalid base_string:GET&amp;https%3A%2F%2Fwww.google.com%2Faccounts%2FOAuthGetAccessToken&amp;oauth_consumer_key%3Dmydomain.com%26oauth_nonce%3D4432dc4bd59b4ea0b133ea52cb450062%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1315724016%26oauth_token%3D4%252FGeEWOLvQL_eGlj8zAdrzi7YPhmhS%26oauth_verifier%3DMkGYPy8qeZPRg7gLKKXsYIiM%26oauth_version%3D1.0 Callback = http://mydomain.com/auth ConsumerKey = mydomain.com ConsumerSecret = RxGavGhuXi92sy3F-Q3DKcY_ Nonce = 4430dc4bd59b4ea3b133ea52cb450062 Scope = https://docs.google.com/feeds SignatureMethod = HMAC-SHA1 Timestamp = 1315724016 Token = 4/GeAWOLvQL_eGlj1zEerzi7YPhmhS TokenSecret = Verifier = MkXLPy8qeZARq7aLKXKsYIiM </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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