0
votes

Per Google's documentation on using service account, this is what I did so far.

  1. Created JWT (json web token) with following payload.

    {"iss":"XXXXXXXX.gserviceaccount.com",
    "aud":"https://www.googleapis.com/oauth2/v4/token",
    "iat":"1465531250",
    "exp":"1465534850",
    "scope":"email profile}
    
  2. Using Postman, I did http post as follows in the hope of getting back the oAuth2 access token.

    URL: https://www.googleapis.com/oauth2/v4/token

    Headers:

    Content-Type: application/x-www-form-urlencoded
    grant_type: urn:ietf:params:oauth:grant-type:jwt-bearer
    assertion: <the JWT generated in step 1 above>
    

Instead, I got error response as follows.

{
  "error": "invalid_request",
  "error_description": "Required parameter is missing: grant_type"
}

Can someone find what is wrong with my request?

I have even tried a different endpoint of "https://accounts.google.com/o/oauth2/token" with grant_type of "authorization_code" as well as "http://oauth.net/grant_type/jwt/1.0/bearer". That too returned the same exact error!

1

1 Answers

0
votes

The grant_type and assertion parameters are not passed as request headers but as post request parameters (grant_type=xxxxxx&assertion=yyyyy)