0

I am trying to access to an API that uses OAuth2 authentication with the Refresh Token grant.

So, to request this API, I need a Client Id, a Client Secret and a Refresh Token.

Using https://console.cloud.google.com/apis/credentials, I created a new OAuth 2.0 Client ID, which gives me a Client Id and a Client Secret.

But I struggle generating a Refresh Token.

By looking at this article, it looks like I need to execute the following POST query :

curl -X POST -d "code=[CODE]&client_id=[CLIENT_ID]&client_secret=[CLIENT_SECRET]&redirect_uri=[REDIRECT_URI]&grant_type=authorization_code" https://oauth2.googleapis.com/token

To retrieve the CODE parameter, I need to do another call to this URL : https://accounts.google.com/o/oauth2/v2/auth?scope=[SCOPE]&access_type=offline&include_granted_scopes=true&response_type=code&redirect_uri=[REDIRECT_URI]&client_id=[CLIENT_ID]

This call opens the Google login page.

enter image description here

However, I don't know how to log in with an OAuth 2.0 Client ID. I don't have an email linked to these credentials.

Am I following the correct steps to retrieve a Refresh Token in my use case, and if so, what am I missing here ?

Nakeuh
  • 1,757
  • 3
  • 26
  • 65
  • After reading [this](https://cloud.google.com/blog/products/data-analytics/connecting-data-fusion-to-the-vision-api-via-oauth-restful-apis#:~:text=NOTE%3A%20You%20may,a%20different%20org.) I assume that you should log in with your GCP user in order to get redirected to http://localhost:8080/.... – J.Vander Feb 03 '22 at 12:48
  • Does this answer your question? [Get refresh token google api](https://stackoverflow.com/questions/8942340/get-refresh-token-google-api) – Pit Feb 08 '22 at 09:35

0 Answers0