# Oauth2 connection, how to refresh oauth2 token automatically

**URL:** <https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679>\
**Category:** Questions\
**Tags:** oauth, connections, api\
**Created:** [February 26, 2024, 12:05pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679 "2024-02-26T12:05:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![pplanejane](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@pplanejane](https://community.make.com/u/pplanejane)\
**Post date:** [February 26, 2024, 12:05pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/1 "2024-02-26T12:05:36Z")

</div>

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?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/3/7/37b1d32abd836454fb0852729c423dce205bb5c8.png)

---

<div class="post-metadata">

**Author:** ![Amadio\_Gabriel](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/amadio_gabriel/32/17547_2.png) [@Amadio\_Gabriel](https://community.make.com/u/Amadio_Gabriel)\
**Post date:** [February 26, 2024, 1:46pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/3 "2024-02-26T13:46:26Z")

</div>

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](https://developers.google.com/identity/protocols/oauth2/web-server#creatingclient). If the issue persists then please let me know.

Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 26, 2024, 1:50pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/4 "2024-02-26T13:50:04Z")

</div>

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](https://console.cloud.google.com/apis/library/indexing.googleapis.com)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/4/d4727c4eee0426b3415b3cc285eb46d47d9dc6ad.png)

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

**Direct Link:** [https://console.cloud.google.com/apis/credentials](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](https://www.make.com/en/help/tutorials/calling-google-apis-via-the--http-make-a-oauth-2-0-request--module) **← FOLLOW THIS**

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/f/5/f59867d6acc5f7106f8a55305b54d6e8f1d1a516.png)

Here are all the known redirect URIs you need for your [Google Cloud Console](https://console.cloud.google.com/) OAuth app. If you set these up, you can reuse the same GCP app for other Google apps and modules on Make.

```plaintext
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](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](https://console.cloud.google.com/apis/credentials/consent)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/8/a84332556db5eb5aac7952030e9f6ac129d2c792.png)

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

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/6/8/68f653cb3050943caef7ce4e18f306b4f5f2ad26.png)

# 4. Configure the HTTP OAuth2 module

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

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/4/3/43df2cd92abedfda53a23fc12991dbfb13eff1be.png)

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:

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/e/aeb4ff9ca8e4f5ddf3badd144b4f5a4fb19f27ef.png)

 ![](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/8/9/89a1c01d161c36bc11d1e7460256be7e02258d18.png)

---

<div class="post-metadata">

**Author:** ![pplanejane](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@pplanejane](https://community.make.com/u/pplanejane)\
**Post date:** [February 28, 2024, 11:24am UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/5 "2024-02-28T11:24:03Z")

</div>

> [@samliew](#):
>
> redirect\_uri

All I need is push into production?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/d/e/de87e5f9a073cd73086b20262e92a4ad92bde93d.png)  
its okay, that it ‘needs verification’?

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 28, 2024, 12:22pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/6 "2024-02-28T12:22:39Z")

</div>

> [@pplanejane](#):
>
> 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](https://community.make.com/t/gmail-google-drive-verification-issues-error-400-how-to-solve/27432)

---

<div class="post-metadata">

**Author:** ![pplanejane](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@pplanejane](https://community.make.com/u/pplanejane)\
**Post date:** [February 28, 2024, 12:26pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/7 "2024-02-28T12:26:45Z")

</div>

Okay, I already do it, but after one hour (acces token expiration time) connecting lost, and I should reconnect it mannually  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/c/c/cc9e6f9dea17b4ded74a76d07645dc7ceb17bd02.png)

---

<div class="post-metadata">

**Author:** ![Zsombor\_Sentes](https://avatars.discourse-cdn.com/v4/letter/z/6a8cbe/32.png) [@Zsombor\_Sentes](https://community.make.com/u/Zsombor_Sentes)\
**Post date:** [March 7, 2024, 2:49pm UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/8 "2024-03-07T14:49:46Z")

</div>

I think the problem is the following:  
([Not getting refresh token in YouTube OAuth - Stack Overflow](https://stackoverflow.com/questions/40811386/not-getting-refresh-token-in-youtube-oauth))  
I tried to put the follwoing two parameters to get a refresh token:  
access\_type=offline  
prompt=consent

 ![SCR-20240307-ougy](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/7/97269a5e4539d53eadf8abb6251ac6d727d756bb.png)

---

<div class="post-metadata">

**Author:** ![hugo2](https://avatars.discourse-cdn.com/v4/letter/h/db5fbb/32.png) [@hugo2](https://community.make.com/u/hugo2)\
**Post date:** [March 25, 2024, 8:14am UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/9 "2024-03-25T08:14:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [April 11, 2024, 8:45am UTC](https://community.make.com/t/oauth2-connection-how-to-refresh-oauth2-token-automatically/28679/10 "2024-04-11T08:45:16Z")

</div>


