# Refreshing OAuth2 token automatically

**URL:** <https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355>\
**Category:** Questions\
**Tags:** http-request, oauth2, google\
**Created:** [July 20, 2023, 12:03pm UTC](https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355 "2023-07-20T12:03:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omnibas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/omnibas/32/27519_2.png) [@Omnibas](https://community.n8n.io/u/Omnibas)\
**Post date:** [July 20, 2023, 12:03pm UTC](https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355/1 "2023-07-20T12:03:28Z")

</div>

Hi everyone, new to the forums and plan to contribute.

I have created a workflow to send a push notification to users from Firebase cloud messaging. I used the method described here: [Firebase Push Notification via HTTP Node - #5 by hamidrexa](http://community.n8n.io/t/firebase-push-notification-via-http-node/2742/5) (had to use the generic oauth2 api as for the google one, the scope I need is not supported.

Now I am running into the following problem: after a while I need to reauthenticate with my google account for the http node to still work. Otherwise I get a warning that the token is no longer valid.

Any thoughts on how to fix this? Could not find the answer on the forum.

---

<div class="post-metadata">

**Author:** ![EmeraldHerald](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/emeraldherald/32/35355_2.png) [@EmeraldHerald](https://community.n8n.io/u/EmeraldHerald)\
**Post date:** [July 20, 2023, 2:57pm UTC](https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355/3 "2023-07-20T14:57:11Z")

</div>

Hi @Omnibas 👋 Welcome to the community!

Would you be able to provide some steps on how to reproduce your problem?

I’m curious if you’re running into something such as a query parameter being wrong such as not setting `access_type=offline` in the oauth credentials, or something else that Google might need, or even this issue with the oauth token being a test user:

> [@Google Calendar OAuth - refresh token](http://community.n8n.io/t/google-calendar-oauth-refresh-token/17178/2):
>
> Hi @danielrubak, seeing this is happening every seven days for you, I suspect this isn’t a problem with n8n not attempting the refresh but rather with Google not allowing the refresh. You might need to publish the OAuth2 client you have registered with Google, as for test users the authentication will expire after seven days as per [Google’s documentation](https://support.google.com/cloud/answer/10311615#zippy=%2Cinternal%2Cexternal%2Ctesting): Authorizations by a test user will expire seven days from the time of consent. From testing this myself it seems Google doesn’t enforce th…

But if you could tell us what all is needed to test this, I’d be happy to look into it 🙂

---

<div class="post-metadata">

**Author:** ![Omnibas](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/omnibas/32/27519_2.png) [@Omnibas](https://community.n8n.io/u/Omnibas)\
**Post date:** [July 21, 2023, 9:11am UTC](https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355/4 "2023-07-21T09:11:23Z")

</div>

I did indeed not see access\_type=offline, lets see if that fixes the problem. The placeholder confused me, I thought it was already set. Thanks, I will let you know if it works.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [October 19, 2023, 9:12am UTC](https://community.n8n.io/t/refreshing-oauth2-token-automatically/28355/5 "2023-10-19T09:12:09Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
