Cybersecurity

n8n Google OAuth token expired after 7 days: fix it

If your n8n Google OAuth token expired after 7 days, reconnect it, check the app’s Testing status, and fix the consent screen before reauthorizing.

Google Cloud OAuth consent screen settings for n8n credentials
Google Cloud OAuth consent screen settings for n8n credentials

If an n8n Google credential stops working almost exactly seven days after authorization, the usual cause is a refresh token issued while an External Google OAuth app was in Testing—not a normal access-token timeout. Reconnect the credential for immediate recovery, then move the app to the appropriate published status and authorize it again. If the error appears immediately, affects only one workflow, or does not recur on a seven-day cycle, investigate the credential, scope, account, API, or redirect configuration instead.

Why the Google credential fails after seven days

The seven-day pattern usually points to Google’s OAuth consent-screen Testing status. For an External app in Testing, Google says authorization by a test user expires seven days after consent, and the associated offline refresh authorization expires with it. Gmail, Sheets, Drive, and similar n8n nodes can then fail when the stored credential can no longer obtain a new access token.

An access token is the short-lived credential used for an API request. When it expires, n8n should use the refresh token stored with the credential to request another access token. That exchange normally happens without another sign-in.

A refresh token is different: it is the credential n8n uses to renew access tokens in the background. If Google expires or revokes it, n8n cannot repair the connection with another background refresh. You need to authorize the credential again.

SymptomLikely meaningNext action
One request returns an access-token-expired or similar 401 responseThe access token or refresh exchange may have failed temporarilyInspect the execution and retry only after checking the credential
invalid_grant with Token has been expired or revokedThe refresh token is no longer usableReauthorize the credential
Several workflows fail about seven days after the same consent eventTesting-status expiry is the leading explanationCheck the Google Cloud project and consent-screen status

The existing token does not become permanent when you change the app later. If you publish the app after the seven-day token was issued, reconnect the n8n credential so Google grants a new token under the updated configuration.

Before you start: confirm the diagnosis

Start with timing, then check the error and the Google Cloud project used by the OAuth client. A single Google 401 does not prove that the seven-day rule is involved.

  1. Record when the credential last worked and when it was last authorized. A failure that returns about seven days after consent supports the Testing-status explanation.
  2. Open the failed n8n execution and inspect the underlying Google response. invalid_grant and Token has been expired or revoked point more strongly to an unusable refresh token than to an ordinary expired access token.
  3. Check whether several workflows using the same credential fail together. If Gmail, Sheets, or Drive nodes sharing that credential stop at roughly the same time, the credential is the likely common point. If only one workflow fails, inspect its node, account, resource, scopes, and API settings first.
  4. In Google Cloud Console, open the project that owns the OAuth client configured in n8n. Check the OAuth consent screen or app-audience status. Checking a different project is a common source of confusion.
  5. Confirm whether the app is External and still in Testing. Google documents that test-user authorizations expire seven days after consent, including the related offline refresh authorization.
  6. Confirm whether the n8n deployment is Cloud or self-hosted before reconnecting. The callback URI and client setup differ between those deployment types.

Stop treating the seven-day explanation as established if the failure happens immediately, only after a scope change, or only for one Google account. Those patterns fit a redirect mismatch, denied consent, revoked access, replaced client, or changed permission more closely.

Reconnect the n8n credential safely

Reauthorization is the quickest reversible recovery. Keep the existing credential until the replacement connection works, especially when production workflows depend on it.

  1. Note the credential name, the workflows that use it, the intended Google account, and the Google resource the workflow should access. For a business-critical workflow, prepare a controlled test rather than testing an unreviewed change against live data.
  2. In n8n, open the Google credential used by the failing node and choose its OAuth reconnect or sign-in action. The label can vary by n8n version and credential type.
  3. Sign in with the intended Google account. Review the requested scopes and approve them only when they match the workflow’s needs. Gmail, Drive, and Sheets access can require different scopes, and a scope change can trigger a new consent prompt.
  4. If n8n asks for a client ID and client secret, verify that both belong to the same Google Cloud project whose consent screen you checked. Do not put an access token or refresh token in a client-secret field.
  5. Confirm that the redirect URI shown by n8n is registered exactly in the Google OAuth client. For n8n Cloud, use the redirect URI and setup values shown in the current n8n Cloud credential instructions. For self-hosted n8n, use the callback URI generated for that installation together with its public URL configuration. A Cloud callback cannot be substituted for a self-hosted callback.
  6. Save the credential and run a low-risk test against the same kind of Google resource used by the workflow. The expected result is a saved credential and a test execution without an OAuth error.
  7. Only after that test succeeds, confirm or update the production workflows that reference the credential.

Reconnecting an existing credential normally preserves the credential identity selected by its workflows. Creating a separate credential can require you to edit each workflow node to select it. Keep the old credential until the replacement path is confirmed; remove or disable it only after checking that no workflow still depends on it.

If Google returns redirect_uri_mismatch, stop authorizing and correct the registered callback. If it returns access_denied, check the selected account, test-user list, consent decision, and organization policy. If the app is reported as not configured, check that the OAuth client, consent screen, enabled Google APIs, and requested scopes belong to the same project.

Move the app out of Testing for ongoing workflows

Testing is useful during development, but it is a poor fit for an unattended n8n workflow that must continue beyond the short refresh-token period. When the app is ready for ongoing use, move the consent-screen publishing status to Production, then reconnect the n8n credential.

In Google Cloud Console, first identify the project used by n8n. Review the user type, publishing status, authorized domains, test users, requested scopes, and OAuth client. Google’s labels, publishing steps, and verification requirements can change, so check the current Google OAuth documentation and Google Cloud Console before publishing or submitting the app for review.

Production does not remove every OAuth failure. Review or verification can still depend on the app, user type, requested scopes, audience, branding, and Google’s current policies. Sensitive or restricted scopes can require additional review. Do not rely on old tutorials for user limits or verification exceptions; confirm the current requirements for this project in Google’s documentation.

For a Google Workspace organization, an Internal audience may fit a workflow limited to that organization. A personal account or an app serving users outside one Workspace organization may require an External configuration. The choice depends on who must authorize the app, not on whether n8n runs in Cloud or on your own infrastructure.

Publishing does not rescue a refresh token that was already issued in Testing. Reauthorize after changing the status. If you cannot publish yet, a Testing setup requires planned reconnects and is not a durable unattended configuration.

If reauthorization still fails

Use the exact failure as the next branch in the diagnosis.

  • redirect_uri_mismatch: the callback registered in Google does not exactly match the URI n8n sends. Recheck whether the client is for n8n Cloud or self-hosted n8n, then correct the Google OAuth client rather than repeatedly authorizing.
  • access_denied: authorization was refused or blocked. Check the Google account, test-user configuration, consent decision, and organization policy.
  • An app-not-configured message: check that the OAuth client, consent screen, enabled Google APIs, and scopes are complete and belong to the project n8n actually uses.
  • invalid_grant immediately after reconnecting: check the client ID and current client secret, then authorize with the intended account. A replaced OAuth client cannot use tokens issued for the old client.

A password change, explicit Google account revocation, changed scopes, or provider-side token limits can also invalidate authorization. Those cases are not fixed by waiting seven days or merely changing Testing to Production. Replace the stale connection only when you have a working authorization path, then grant the scopes the workflow actually needs.

Keep the current n8n and Google OAuth documentation available while troubleshooting. UI labels, callback requirements, and verification rules can change, so confirm the applicable instructions for your n8n deployment and Google Cloud project.

Verify the fix and prevent a silent recurrence

After reconnecting, check the complete path rather than stopping at the Google consent page:

  • The n8n credential saves without an OAuth error.
  • A test node can read or write the intended Google resource.
  • The selected Google account owns or can access that resource.
  • The credential has the scopes the workflow needs.
  • A scheduled or production-like execution succeeds without manual sign-in.
  • Other workflows using the credential still reference the intended credential.
  • The Google project, OAuth client, consent screen, and n8n callback belong together.

For ongoing operations, add an n8n error-handling or Error Trigger workflow that alerts you when the Google credential fails. Test that alert separately. If the app remains in Testing, treat reconnecting as planned maintenance rather than assuming the credential will remain valid indefinitely.

Conclusion

Check the timing and the Google error first. If the credential fails with a refresh-token error about seven days after consent, reconnect it, publish the correct consent-screen configuration, authorize again, and complete a controlled workflow test before returning to unattended runs.

Frequently Asked Questions

Does changing Google OAuth from Testing to Production immediately fix the existing n8n credential?

No. The refresh token already issued in Testing can retain its seven-day expiry. Change the status, reconnect the n8n credential, and run a controlled workflow test before relying on it for scheduled production work.

Why does only one n8n Google workflow fail?

That pattern does not prove a seven-day refresh-token failure. Check whether the workflow uses a different credential, Google account, scope, API, or resource. If several workflows share one credential and fail together near seven days, Testing status is more likely to be the cause.

Can I fix this by copying a Google access token into n8n?

No. An access token does not restore the refresh flow and is not a durable fix. Reauthorize the n8n Google credential through OAuth with the correct client, redirect URI, account, and scopes.

Sources

Security & Systems Desk

Think Tech Editorial

Practical Linux networking, container hardening, and zero-trust infrastructure playbooks.