Oauth2 connection, how to refresh oauth2 token automatically

I created ouath2 connection to YouTube DATA API and it works well, until token had expired.
What can I do, to handle this automatically, to get new token every time automation is running?

Hi there,

Could you please let me know if your Google OAuth app is set to Production or if it is in Testing? If it’s in Testing, please try changing it to production and the connection should no longer be invalidated after 7 days.

​If your connection is failing in less than a day, please make sure to add the access_type: offline header to the connection parameters as specified in the Google documentation. If the issue persists then please let me know.

Thanks! :slight_smile:

1 Like

You might need some help with step 3 (and maybe step 4) below:

If you do this correctly, the connection should handle this for you.

1. Enable the API

Direct Link: Google Cloud console

2. Insert all the known Google Redirect URIs for your app

Direct Link: https://console.cloud.google.com/apis/credentials

How to create an OAuth app in GCP: https://www.make.com/en/help/tutorials/calling-google-apis-via-the--http-make-a-oauth-2-0-request--module ← FOLLOW THIS

Here are all the known redirect URIs you need for your Google Cloud Console OAuth app. If you set these up, you can reuse the same GCP app for other Google apps and modules on Make.

https://www.make.com/oauth/cb/oauth2
https://www.make.com/oauth/cb/google-custom
https://www.make.com/oauth/cb/google-restricted
https://www.make.com/oauth/cb/google-cloud-speech
https://www.make.com/oauth/cb/google-analytics-4
https://www.integromat.com/oauth/cb/oauth2
https://www.integromat.com/oauth/cb/google-custom
https://www.integromat.com/oauth/cb/google-restricted
https://www.integromat.com/oauth/cb/google-cloud-speech
https://www.integromat.com/oauth/cb/google-analytics-4

Once you’ve set these up, you can use/reuse the same Make connection for all the supported Google apps & modules on Make - you’ll only have to enable the respective APIs for your custom app in Google Cloud.

3. Publish your GCP OAuth2 app

Direct Link: https://console.cloud.google.com/apis/credentials/consent

You might need to set your OAuth application to “Production”, otherwise the credentials expire very frequently.

1. To do this, go to menu item “OAuth consent screen”

or click here https://console.cloud.google.com/apis/credentials/consent

2. Then click the button below if the Publishing status is not “In production”

4. Configure the HTTP OAuth2 module

You need a “Authorize parameters” key of redirect_uri with the above Make OAuth2 callback URL.

You can find the Client ID and Client Secret in the OAuth2 app you created in GCP, on the right-hand side of where you inserted the 8 callback URLs in step 2:

2 Likes

All I need is push into production?


its okay, that it ‘needs verification’?

You do not need to verify your app. See Gmail/Google Drive verification issues (error 400): how to solve

2 Likes

Okay, I already do it, but after one hour (acces token expiration time) connecting lost, and I should reconnect it mannually
image

I think the problem is the following:
(Not getting refresh token in YouTube OAuth - Stack Overflow)
I tried to put the follwoing two parameters to get a refresh token:
access_type=offline
prompt=consent

4 Likes

Hello. Have you found the solution ? I have the same problem.