title: OAuth2 "Invalid Grant" response from server
body: <p>I ask my client to hit at this URL with his authorized gmail account with which he has created the google api project.</p>
  
  <pre><code>https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&amp;response_type=code&amp;access_type=offline&amp;redirect_uri=http://www.XXXXXXXX.com/oauth2callback&amp;client_id=XXXXXX.apps.googleusercontent.com&amp;state=profile&amp;approval_prompt=force
  </code></pre>
  
  <p>and then ask him to provide me the code parameter from the redirected URL</p>
  
  <pre><code>http://www.XXXXXXXX.com/oauth2callback?code=4/jUxc2MdX0xmF-b4_I6v2SLMQMuxO.cvQLVEpcJMUXOl05ti8ZT3ZvsT9ddwI
  </code></pre>
  
  <p>Then i myself post this form with following info.</p>
  
  <pre><code>&lt;form action="https://accounts.google.com/o/oauth2/token" method="post" &gt;
  
  &lt;input type="hidden" name="grant_type" value="authorization_code" &gt;
  &lt;input type="text" name="code" value="**is the one i recieved from previous step**"&gt;
  &lt;input type="hidden" name="client_id" value="XXXXXXX.apps.googleusercontent.com" &gt;
  &lt;input type="hidden" name="client_secret" value="XXXXXXXXXXXX" &gt;
  &lt;input type="hidden" name="redirect_uri" value="http://www.XXXXXX.com/oauth2callback" &gt;
  &lt;input type="submit" value="Submit"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>and then i get the following error</p>
  
  <pre><code>{
      "error" : "invalid_grant"
  }
  </code></pre>
  
  <p>When i generate the code url param myself and perform the next step. i am successfully presented with following response</p>
  
  <pre><code>{
    "access_token" : "XXXXXXStBkRnGyZ2mUYOLgls7QVBxOg82XhBCFo8UIT5gM",
    "token_type" : "Bearer",
    "expires_in" : 3600,
    "refresh_token" : "XXXXXX3SEBX7F2cfrHcqJEa3KoAHYeXES6nmho"
  }
  </code></pre>
  
  <p>But if the client generate the url param "code" then i see the invalid grant error.</p>
  
  <p>My Client is in UK and i am in another country. Can anybody please confirm if it's the error because client is generating the code param in another country and i am using that code in another country ?</p>
  
  <p>Thanks in advance.</p>