OAuth2 token expires every 7 days for Google Drive (n8n Cloud, private Google account) – how to make it persistent?

Hi n8n team and community :waving_hand:

I’m using n8n Cloud on my instance: lavanderdesign.app.n8n.cloud and have several workflows connected to Google Drive and Google Search Console using OAuth2 authentication.

I’m using my personal (private) Google account – not Google Workspace.

The issue I’m facing is that the Google connection breaks every ~7 days. I need to manually reconnect OAuth in the credentials section, which is disruptive and makes automation unreliable.

I understand that n8n Cloud uses a shared redirect URI:
https://oauth.n8n.cloud/oauth2/callback

But from my experience, the token lifetime for Google seems shorter with this shared redirect, possibly because it’s used by many users.

I’d like to ask:

  1. Can you enable OAuth Proxy for my instance, so I can use my own Google OAuth2 credentials with this redirect URI:
    https://lavanderdesign.app.n8n.cloud/rest/oauth2-credential/callback
  2. If that’s not possible, is there any stable workaround to prevent Google tokens from expiring every 7 days?

For example:

  • Is there a way to refresh the token programmatically?
  • Would using a Google Service Account help (even on a private Google account)?
  • Or any other best practices to keep Google apps connected longer?

Any advice or confirmation from the n8n team would be appreciated! :folded_hands:

Thanks in advance and great job on the platform – I love n8n!

Best regards,
Sebastian

Does this answer your question:

No at all. The article just describes the problem and says you have to reconnect manually… :frowning:

No, it absolutely does also say For Google Cloud apps with Publishing status set to Testing and User type set to External, which implies that this is what causes it.

This limitation is set in the Google Cloud OAuth itself, read here.

Yes, but it also applies to apps set to production and unverified. Is there really no way how to use google apis without having to refresh the token manualy every seven days?
Since this is only a “one user connection” and not really a public app it makes no sense to have it verified. On top n8n has a default scope for Google drive that includes acces to user photos which would be really tough to explain to the verification team…
Do you have an idea how to solve this?

It does work by setting it to public and never verifying it.
It works like that indefinitely, it just shows a warning when you login saying it’s unverified.

Checkout the thread here. This has been discussed a lot in the forum

If you need to limit your scopes then just dont add those scopes in the google api console. You need to manually add in any scopes you want to use.

If you want more control over the scopes, you can use generic oauth credential and set your scopes manually, but then you need to do the requests manually through the http node

1 Like

Thanks for you answear Liam! You’re giving me hope :slight_smile:
Is it possible it differs on selfhosted versions? Because my app is unverified, in production, working but every seven days authentication fails and I have to sign in again.

It’s the same for self hosted

Without being able to get eyes on your cloud console I’d say maybe try starting a new connection and try again ensuring you select all the options from the docs

Unfortunately oauth can be tricky like this. It’s actually much easier on the cloud version, for most services you don’t need to register your own app it just works since n8n does all the oauth work behind the scenes

1 Like