Google OAuth Error 400: invalid_request when using n8n on Fly.io

I’m running n8n (workflow automation tool) on Fly.io, and it works fine. Now I’m trying to connect Google services like Gmail or Google Sheets using OAuth2.

I created a Google Cloud OAuth 2.0 Client ID, and I added the client_id and client_secret in n8n credentials. But when I try to authenticate, I get this error from Google:

Access blocked: Authorization Error  
Error 400: invalid_request  
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy

In the error URL, I see:

redirect_uri=https://flyn8n-thrumming-feather-2258.fly.dev/rest/oauth2-credential/callback

In my Google Cloud Console, I added this exact redirect URI:

https://flyn8n-thrumming-feather-2258.fly.dev/rest/oauth2-credential/callback

I also set up the OAuth consent screen in testing mode and added my Gmail as a test user.

But the error is still there.

What I already did:

  • Checked that the redirect URI matches 100% App is in Testing mode, and my account is listed as test user

Dear @Miiloud How’s everything going on with you !

Regarding the problem you are facing, it’s happening because you have forget to add your email id inside audience section of Google Console.

So, when to generate Client ID and Secre, you have autheticate inside Google Console, you have done everything right.

But forget to add the Email Id inside audience section.

Solution,

Please go and add your Email ID inside audience section and it will start working.

Rememdation :- If possible please create the new OAuth.

Happy to help.

(If this solve the problem, then please mark it as solution, because this will help others too.)

I add my email inside audience (test users) but doesn’t work

Did you add thise scopes to the enabled permissions on the app

If you want production use from Fly.io:

  • Get a custom domain + SSL
  • Complete google app verification