If your n8n workflow returns The OAuth client was not found or Error 401: invalid_client when using Google Sheets, the fix is usually a single mismatch: the Google OAuth client does not match the redirect URI or project where you enabled APIs. Correct the OAuth client, add the exact redirect URI n8n shows, enable the Sheets and Drive APIs, then re-authenticate.
Why this google sheets oauth error happens
Google rejects OAuth flows when the client ID or redirect URI do not match the values registered in the Google Cloud project. Common causes are:
- Using credentials from the wrong Google Cloud project, or from a deleted project.
- Redirect URI mismatch, including http vs https, missing or extra trailing slash, or wrong hostname or port.
- Not enabling the
Google Sheets APIand, when needed, theGoogle Drive APIin the same project as the OAuth client. - Using an API key or service account where OAuth client ID is required.
Step by step fix (tested checklist)
- Open Google Cloud Console, create or pick a project, then enable APIs: search for and enable Google Sheets API and Google Drive API (if your flows read or write spreadsheets stored on Drive).
- Go to APIs & Services > OAuth consent screen. Choose External for public automation or Internal for G Suite accounts, add your app name and support email, and add these test scopes if asked:
https://www.googleapis.com/auth/spreadsheetsandhttps://www.googleapis.com/auth/drive. Save. - Go to APIs & Services > Credentials and create an OAuth 2.0 Client ID. For Application type choose Web application.
- Add the exact redirect URI n8n needs. For self hosted n8n running at your domain copy this exact pattern, replacing
YOUR_DOMAIN:
For local testing with the default n8n port use:https://YOUR_DOMAIN/rest/oauth2-credential/callback
If you use n8n Cloud or a managed workspace, copy the redirect URI shown in your n8n credential creation screen. Do not guess. Exact values matter.http://localhost:5678/rest/oauth2-credential/callback - After creating the client, click the download icon to get the JSON, or copy the
Client IDandClient secret. - In n8n open Credentials and create a new Google Sheets OAuth2 credential. Paste the
Client IDandClient secretinto the credential fields. For the Redirect URI field in Google Cloud, ensure it exactly matches what n8n told you to use earlier. - Back in n8n click the button to connect or authenticate. When prompted, sign in with the Google account that has access to your sheets, approve the scopes. If you need long running access, grant offline access so a refresh token is issued.
- If you saw
Error 401: invalid_clientor the oauth client was not found error again, re-check that the client ID in n8n matches the JSON and that the redirect URI in the Google Cloud console is byte for byte identical to the URI n8n provided. Common gotchas are missing trailing slashes, http vs https, or wrong port.
n8n specific notes for the Google Sheets OAuth flow
n8n shows the exact redirect URI to use when you create an OAuth2 credential. In the Credentials screen pick the Google Sheets credential type, then look for any helper text or a copy button that gives the Redirect URI. Use that exact string in Google Cloud Console under your OAuth client Authorized redirect URIs.
Typical values you can copy and adapt:
- Self hosted production:
https://mydomain.com/rest/oauth2-credential/callback - Local n8n:
http://localhost:5678/rest/oauth2-credential/callback
If your n8n instance is behind a proxy or load balancer, ensure the external URL that users open is the same host used in the redirect URI. If you still have problems, the n8n community thread about this error contains real user reports and fixes, see this n8n forum thread on The OAuth client was not found.
Troubleshoot tokens, permissions and common pitfalls
- If the consent screen is not published, test accounts are limited. Add your Google account to the test users list under OAuth consent screen, or publish the app if ready.
- Confirm the OAuth client belongs to the same project where you enabled the Sheets and Drive APIs. Enabling APIs in a different project will not help.
- Check that the n8n Google Sheets credential requests the correct scopes. At minimum use
https://www.googleapis.com/auth/spreadsheets. If you need to open files on Drive also includehttps://www.googleapis.com/auth/drive. - When you update redirect URIs or client secrets, you must re-authenticate from n8n to obtain a fresh access token and refresh token. Old tokens may be invalid after changes.
- If you see
invalid_clientwhile using a Client ID that looks correct, verify there are no hidden characters or line breaks when copying. Paste into a plain text editor to confirm.
How to stop this recurring problem
- Document the Google Cloud project name, Client ID and the exact redirect URI used for each n8n workspace.
- Use environment variables or secrets to store client ID and secret securely, and avoid recreating credentials unnecessarily.
- When moving n8n between hosts, update the redirect URI first, then re-authenticate. Test on a single spreadsheet before deploying widely.
When to get help
If you followed the checklist and still get The OAuth client was not found or Error 401: invalid_client, collect these items before asking for help: exact error text, the redirect URI you registered, the client ID shown in Google Cloud, and whether the Google Sheets and Drive APIs are enabled in the same project. Post them on the n8n community or consult a developer who manages your n8n host. For related thread discussion see this additional post about credential types and triggers about HubSpot credential differences, which highlights how triggers and actions sometimes need separate credentials.
If you want examples and a walkthrough of other n8n troubleshooting steps, see our post on webhooks Fix n8n webhook not receiving data.
Learn to build automations like this with Automate Naija, where we teach practical n8n and AI automation skills.
Frequently asked questions
What exactly causes the oauth client was not found error with Google Sheets?
That error means Google cannot find a matching OAuth client for the request. Usually the Client ID or Authorized redirect URI in the Google Cloud Console does not match the values used by n8n. It can also happen if you enabled the API in a different project or used a service account instead of an OAuth client ID.
What redirect URI should I add for a local n8n install?
For a default local n8n install add this redirect URI exactly: http://localhost:5678/rest/oauth2-credential/callback. If you run n8n on a different port or a reverse proxy, use the external URL users open, not the internal container address.
Do I need the Google Drive API as well as Sheets?
If your workflow only accesses cell data you can use the Sheets scope. If your workflow opens, lists, or creates files on Drive, enable the Google Drive API and include the Drive scope: https://www.googleapis.com/auth/drive. Enabling both avoids permission errors when n8n needs to open spreadsheets stored in Drive.
After fixing the redirect URI I still get invalid_client, what else should I check?
Verify the Client ID and Client secret in n8n match the JSON from Google, re-authenticate to get a new refresh token, ensure the OAuth consent screen has your account as a test user if unpublished, and confirm the OAuth client is in the same Google Cloud project where Sheets API is enabled.
Build it with us. The community is free and the build track teaches this kind of automation week by week: see pricing or join the community.