title: Google GData .Net OAuthUtil.GetAccessToken 400 Bad Request
body: <p>I'm trying generate an OAuth access token via the Google .Net GData Client Library. I've been using the instructions in <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> as a guide and everything's been working up until I attempt calling <code>OAuthUtil.GetAccessToken( parameters )</code> at which point I receive a "(400) Bad Request" web exception. </p>
  
  <p>Unfortunately, it's not telling me anything about <em>why</em> it's a bad request. So, I'm kinda baffled about this. The only idea I have is that, because I'm using a <code>localhost</code> url it's not working (though I have registered the url in the Google API Console and it seemed to be okay to do so).</p>
  
  <p>Any ideas what I'm doing wrong here and what I should be doing to make it right? </p>
  
  <p>The <code>OAuthParameters</code> object is constructed like so (<em>sensitive data is censored, hope that doesn't make it hard to answer</em>):</p>
  
  <pre><code>BaseProperties:
      oauth_consumer_key:     &lt;CLIENT_KEY&gt;,
      oauth_nonce:            &lt;NONCE&gt;
      oauth_signature_method: HMAC-SHA1
      oauth_timestamp:        1330440325
      oauth_token:            &lt;TOKEN&gt;
      oauth_verifier:         &lt;VERIFIER&gt;
  Callback:        "http://localhost:57381/subscription_auth.aspx?c=google.calendar"
  ConsumerKey:     &lt;CLIENT_KEY&gt;
  ConsumerSecret:  &lt;CLIENT_SECRET&gt;
  ExtraProperties
      oauth_consumer_secret: &lt;CLIENT_SECRET&gt;
      scope:                 https://docs.google.com/calendar/feeds/
      oauth_callback:        http://localhost:57381/subscription_auth.aspx?c=google.calendar
  Nonce:           &lt;NONCE&gt;
  Scope:           "https://docs.google.com/calendar/feeds/"
  Signature:       NULL
  SignatureMethod: "HMAC-SHA1"
  Timestamp:       "1330440325"
  Token:           &lt;TOKEN&gt;
  TokenSecret:     NULL  -- No Token Secret was returned from the callback.
  Verifier:        &lt;VERIFIER&gt;
  </code></pre>
  
  <p>This translates into headers for the web response which are like so:</p>
  
  <pre><code>Authorization: OAuth oauth_version="1.0",
  oauth_nonce=&lt;NONCE&gt;,
  oauth_timestamp="1330441324",
  oauth_consumer_key=&lt;CLIENT_KEY&gt;,
  oauth_verifier=&lt;VERIFIER&gt;,
  oauth_token=&lt;TOKEN&gt;,
  oauth_signature_method="HMAC-SHA1",
  oauth_signature=&lt;SIGNATURE&gt;
  </code></pre>
  
  <p><em>(line breaks added for readability)</em></p>
  
  <p>NOTE: The above redacted values are encoded correctly where relevant by the GData code.</p>
  
  <p>And the request uri is: <code>https://www.google.com/accounts/OAuthGetAccessToken</code></p>
  
  <p>The error's happening at line 186 as per the class located here: <a href="http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123" rel="nofollow">http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/src/core/oauthutil.cs?r=1123</a></p>