Gmail send email is not working with the error saying - Error 400: redirect_uri_mismatch

Describe the problem/error/question

I am using the gmail send send a message flow. I have selected Credential to connect → From the drop box, selected Create New Credential. Then I have created client id and secret key and pressed ‘Sign In with Google’ where the error saying Error 400: redirect_uri_mismatch

Here I am have redirect url as http://localhost:5678/rest/oauth2-credential/callback which I copied for later use.

But when I create the credential in https://console.cloud.google.com/ in the redirect URL box I was unable to give this redirect url because I am not using the localhost

My n8n workflow launched from oracle cloud free tier Ubuntu system. I have the public IP address from which I am running the n8n, but the same public IP address if I give in google console → redirect URL it is not accepting and it is asking for the domain name. I have copied the Fully qualified domain name from the oracle cloud and successfully created the Cliend ID and Secret Key.

So, I have configured Fully qualified domain name (not the ip addresss) in the google console, but in the n8n it is showing the redirect url as localhost like http://localhost:5678/rest/oauth2-credential/callback,

Hence when I press the ‘SignIn with Google’ the Error 400 is showing.

Not sure where / how to fix this redirect issue.

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Arun1,

Make sure to set the following environment variables as well when you self host n8n to make sure the redirect url displays correctly:

WEBHOOK_URL=https://whatever-your-oracle-host-url-is
N8N_HOST=whatever-your-oracle-host-url-is      ## Without the leading https://
N8N_PORT=5678
N8N_PROTOCOL=https
N8N_SECURE_COOKIE=true

Not sure how you are hosting, but if using docker, it’s just in the config. Restart your instance and see if it displays correctly.

Additional Notes:

  1. You must have a dns record when setting the redirect url in google. Raw IPs will not work
  2. You must have SSL setup for HTTPS

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.