Google login within the Drive node is not working

I’m trying to log into my Google account using OAuth2, but I’m getting an error in the last step, after I grant the permissions. It shows an error as if the page doesn’t exist. Here’s a screenshot. Can anyone help me with this?

Hi @wesleyvforte Welcome to the community!
I see the issue, you are using localHost URL which google cannot actually reach, consider using a webhook URL from a service like NGrok or CloudFlared and set that tunnel link as the webhook_url and then try again by setting n8n with new URL and then adding the redirect URL in the Oauth2 google credential.

@Anshul_Namdev Thanks for the tip. I’m using LocalHost because I’m using n8n as an application within the VPS. I installed it with code in the VPS compose file, and I don’t know if there’s a way to change that link to be able to use it.

1 Like

@wesleyvforte If you really want to connect google credentials with n8n you really need a tunnel to make your local n8n app exposed to the internet, consider watching these videos:

You will get free ngrok account and setup you will get from here, and as you need to set a redirect URL in google cloud console in order to connect to those credentials so for that see this:

And that is how it is done!

Hi @wesleyvforte, welcome to n8n community :tada:
If n8n is running on a VPS, you cannot use localhost in the OAuth flow unless you are accessing it locally through SSH tunneling or port forwarding. Google will always redirect to whatever callback URL n8n generated when the credential was created. So the fix is to make n8n aware of its public URL and register that same URL in Google Cloud. Once both sides match, the login works normally.