Google Sheets n8n credential keeps failing

Hey everyone, I’m stuck on a frustrating OAuth issue connecting n8n to Google Sheets and could use a fresh set of eyes.

My setup:

  • Self-hosted n8n via Docker
  • ngrok for webhook/OAuth redirects

What’s happening:
The OAuth flow gets all the way through, I pick my account, grant permissions, but instead of the “Connection successful” screen, I hit an Unauthorized error right at the end.

What I’ve already tried:

  • Enabled every relevant Google scope
  • Added my ngrok domain to the Authorized domains on the OAuth Branding tab
  • Repeated the flow ~10 times with the same result

What’s confusing me:
This same setup worked for previous integrations. Nothing intentionally changed on my end, one credential just randomly stopped working and now I can’t get any new Google connections to authorize either.

Has anyone run into this specifically with ngrok + Docker + Google OAuth? Any idea what’s changed or what I might be missing?

That “Unauthorized” at the final step is almost always Google rejecting the OAuth redirect URL, not a scope or permissions issue. With Docker + ngrok in the mix, the most common culprit is a mismatch between:

The callback URL n8n generates for the credential

The Authorized redirect URI you’ve added in your Google Cloud OAuth client

The N8N_EDITOR_BASE_URL / WEBHOOK_URL environment variable n8n is using internally

All three need to match exactly, same protocol, same domain, same path, no trailing slash differences. If even one character is off, Google will let you get all the way through sign-in and then reject you right at the final redirect.

To verify, open the Google Sheets credential in n8n and look at the OAuth Redirect URL it shows you, copy that exact string and make sure it’s listed verbatim in your Google Cloud Console under Authorized redirect URIs.

This does not look like a Google Sheets permission problem yet. It looks like an OAuth callback identity problem.

The clue is that the flow gets all the way through account selection and consent, then fails on the final redirect. That is usually where n8n base URL / webhook URL / Google authorized redirect URI mismatch shows up.

I would stop changing scopes for now and prove one thing first:

Does the redirect URL shown inside the n8n Google Sheets credential match the Google Cloud Authorized redirect URI character-for-character, including protocol, ngrok domain, path, and trailing slash?

Do not post client secrets or tokens publicly. The only safe thing to compare publicly is the redacted callback domain/path shape.

Hey! This is a classic ngrok + Docker OAuth redirect mismatch. Most common causes:

1. ngrok URL changed between sessions
ngrok free tier generates a new URL on every restart. If you restarted ngrok after setting up the OAuth client, the redirect URI in Google Cloud Console no longer matches. Fix: update Authorized redirect URIs in Google Cloud Console to the new ngrok URL: https://<new-ngrok>.ngrok-free.app/rest/oauth2-credential/callback

2. WEBHOOK_URL env var missing or stale
In your Docker Compose you need:

N8N_EDITOR_BASE_URL=https://<your-ngrok-url>
WEBHOOK_URL=https://<your-ngrok-url>

Without these n8n constructs the callback from localhost internally, which never matches what Google expects.

3. Google app in Testing mode
If the OAuth consent screen is in Testing mode, only explicitly listed test users can authorize. Make sure your account is in the test users list.

Quick checklist:

  • Does the redirect URI in Google Cloud Console exactly match <ngrok-url>/rest/oauth2-credential/callback?
  • Is WEBHOOK_URL set in your Docker env?
  • Is your account in the OAuth test users list?

The ‘randomly stopped working’ pattern almost always points to ngrok URL rotation. Let me know what you find!

Sounds like the account you are trying to sign in with is not in the test users group. Add it there and try again.

Audiance > Test Users + Add User