How can I get a Refresh Token from GCP?
I already got the Client ID and Client Secret from OAuth Client ID, but I can't find any Refresh Token from the credentials?
How can I get a Refresh Token from GCP?
I already got the Client ID and Client Secret from OAuth Client ID, but I can't find any Refresh Token from the credentials?
Google provides a lot of docs around different methods of authentication including refresh tokens but this document is probably most helpful.
Basically, once the user authorises you, in the response you get an authorization code which can be exchanged for an access token and refresh token by making a call to https://oauth2.googleapis.com/token
like:
POST /token HTTP/1.1
Host: oauth2.googleapis.com
Content-Type: application/x-www-form-urlencoded
code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&
client_id=your_client_id&
client_secret=your_client_secret&
redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob%3Aauto&
grant_type=authorization_code
Response:
{
"access_token": "1/fFAGRNJru1FTz70BzhT3Zg",
"expires_in": 3920,
"token_type": "Bearer",
"scope": "https://www.googleapis.com/auth/drive.metadata.readonly",
"refresh_token": "1//xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
}
Oauth on GCP is covered in depth here.