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".

Here is the issue:

**Step 1:**

Redirect one of our pages to '<https://accounts.google.com/o/oauth2/auth?scope=email&redirect_uri=https%3A%2F%2Fmyurl.com%2Fcallback&response_type=code&client_id=some_client_id>'

**Step 2:**

The redirection happens and google would redirect to our url 
<https://myurl.com/callback?code=somecode>

**Step 3:**

curl -X POST --data "code=somecode&client\_id=some\_client\_id&some\_client\_secret=some\_client\_secret&redirect\_uri=<https://myurl.com/callback&grant_type=authorization_code>" <https://accounts.google.com/o/oauth2/token> -v --trace-ascii /dev/stout

The response comes back:

HTTP 400 Bad request

{
 "error" : "invalid\_grant",
 "error\_description" : "Invalid code."
}

Can someone help me with this issue? Thanks!