OAuth Integration Issue with Google APIs in n8n on Google Cloud Run - "Unauthorized" Error

Hello n8n Community,

I’m running self-hosted n8n on Google Cloud Run and trying to integrate it with Google OAuth to authenticate and access various Google APIs (e.g., Google Drive, Google Sheets) and trying to create n8n credentials and potentially using those credentials in n8n google nodes like google docs, spreadsheet, drive, etc. I have set up OAuth credentials and the OAuth consent screen in the Google Cloud Console. However, when I try to authenticate with Google via n8n, I am prompted to choose my Google account, where I choose the same account using which I created the credentials and after doing so, I encounter the following error message:

{ “status”: “error”, “message”: “Unauthorized”}

What I’ve Done So Far:

  1. OAuth Credentials in Google Cloud Console:

  2. Google Cloud Console Configuration:

    • OAuth consent screen is set up, in status published and verified. Although, haven’t verified the data access status yet.

    • My Google account ([email protected]) has the highest-level privileges in the GCP project and is used for OAuth authentication and creating credentials.

  3. n8n Configuration:

    • I’ve configured the Google OAuth credentials in n8n and added the correct client ID and client secret.

    • Tried the “Sign in with Google” flow but keep facing the Unauthorized error.

  4. What Happens During OAuth:

    • I select my Google account ([email protected]).

    • I encounter the message “This app is not verified” and click Advanced > Go to ScanX (unsafe).

    • After that, I grant the necessary permissions, but the “Unauthorized” error appears each time.

Things I’ve Tried:

  • Double-checked the OAuth client ID and secret.

  • Verified the redirect URI in both Google Cloud Console and n8n.

  • Ensured that all necessary scopes are added in the OAuth consent screen.

  • Waited for more than 12 hours for the OAuth credentials to propagate in Google Cloud.

  • Ensured that the service account used by Cloud Run has the necessary IAM roles (Editor, Viewer, etc.).

Error Message:

  • After entering the Client ID and Client Secret from the created Oauth credentials, when I click “Sign in with google” in n8n credential, and follow the steps, I get the error message:

Information on my n8n setup

  • n8n version: 1.50.1, self hosted on Google Cloud Run
  • Database: Google Cloud SQL Postgres

Hello @devuser2!
I found that the Google OAuth flow on Cloud Run was failing with Unauthorized simply because Cloud Run was not allowing unauthenticated requests, so Google could not reach the callback endpoint at all, and once I enabled public access and made sure the callback URL in my Google OAuth client matched exactly the one shown by n8n, the authentication flow completed normally.

This is almost certainly a Cloud Run session issue — the container loses your login session between when you click “Sign in with Google” and when Google redirects back to the callback URL, so n8n thinks you’re not authenticated. Add N8N_SKIP_AUTH_ON_OAUTH_CALLBACK=true as an env var in your Cloud Run service config and redeploy, that should fix it.