Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to get OAuth2 token using REST API

Hello,

   I am new to GCP. My goal is to use REST APIs to retrieve my project resources like "list buckets", "list instances" etc... for which I need an OAuth2 token. My attempts to acquire the OAuth2 token using Postman has been failing with this error

{
"error": "unsupported_grant_type",
"error_description": "Invalid grant_type: "
}

Given below is the url I am using for getting OAuth2 Token

https://oauth2.googleapis.com/token

With Headers include:

client_id : <client id from application_default_credentials.json>

client_secret : <client secret from application_default_credentials.json>

refresh_token: <refresh_token from application_default_credentials.json>

type:"authorized_user" 

universe_domain: "googleapis.com"

quota_project_id: <quota_project_id from application_default_credentials.json>

quota_project_id

I am using the values found in application_default_credentials.json created from running "gcloud auth application-default login" command for the values for the header keys (above). Can someone tell me what's wrong ?

1 1 1,202
1 REPLY 1
Top Labels in this Space