0

I tried to get an access token with the google documentation.

curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token? client_id=oauth2-client-id& client_secret=oauth2-client-secret& code=authorization-code& grant_type=authorization_code& redirect_uri=https://www.google.com'

With this request it didn't worked. I added -H 'Content-Length: 0' and now I'm ending up with

{
  "error": "invalid_grant",
  "error_description": "Bad Request"
}

Anybody have an idea?

xk3tchuPx
  • 3
  • 1

4 Answers4

0

it seems you have a space in the request: /v4/token? client_id=oauth2-client-id when i tried to copy past the commands from the documentation it didn't work. i had to re-edit the request before i could use it and it worked.

0

I've got the same issue.

curl -L -X POST "https://www.googleapis.com/oauth2/v4/token?client_id=<client_id>.apps.googleusercontent.com&client_secret=<secret>&code=4/4wGANiKF5......N0Jg&grant_type=authorization_code&redirect_uri=https://www.google.com"

Stumped

K20GH
  • 6,032
  • 20
  • 78
  • 118
0

Don't you have to use a different redirect_uri? Your own configured redirect uri?

0

If fixing the space didn't work, re-do you linking here from the Google guide, steps 1-6. Then get a new authorization code. I had the same issue and re-linking worked for me (with the -H flag).

zonak53
  • 54
  • 7
  • sorry, but that link is apparently related to NEST; what's the URL for step 1 to get an authorization code for a regular Google (NOT NEST) API? – Michael Feb 05 '21 at 18:53
  • There might be API specific documentation, but here is the general [link](https://developers.google.com/identity/protocols/oauth2) – zonak53 Feb 08 '21 at 13:20