title: Google OAuth token exchange returns invalid_code
body: <p>I have been implementing the Google web server OAuth flow, but when I attempted to exchange the authorization code with access token, it always complains "invalid_code".</p>
  
  <p>Here is the issue:</p>
  
  <p><strong>Step 1:</strong></p>
  
  <p>Redirect one of our pages to '<a href="https://accounts.google.com/o/oauth2/auth?scope=email&amp;redirect_uri=https%3A%2F%2Fmyurl.com%2Fcallback&amp;response_type=code&amp;client_id=some_client_id">https://accounts.google.com/o/oauth2/auth?scope=email&amp;redirect_uri=https%3A%2F%2Fmyurl.com%2Fcallback&amp;response_type=code&amp;client_id=some_client_id</a>'</p>
  
  <p><strong>Step 2:</strong></p>
  
  <p>The redirection happens and google would redirect to our url 
  <a href="https://myurl.com/callback?code=somecode">https://myurl.com/callback?code=somecode</a></p>
  
  <p><strong>Step 3:</strong></p>
  
  <p>curl -X POST --data "code=somecode&amp;client_id=some_client_id&amp;some_client_secret=some_client_secret&amp;redirect_uri=<a href="https://myurl.com/callback&amp;grant_type=authorization_code">https://myurl.com/callback&amp;grant_type=authorization_code</a>" <a href="https://accounts.google.com/o/oauth2/token">https://accounts.google.com/o/oauth2/token</a> -v --trace-ascii /dev/stout</p>
  
  <p>The response comes back:</p>
  
  <p>HTTP 400 Bad request</p>
  
  <p>{
    "error" : "invalid_grant",
    "error_description" : "Invalid code."
  }</p>
  
  <p>Can someone help me with this issue? Thanks!</p>