Gmail Authentication Localhost

Hi all, I entered the Gmail OAuth2 API data and when I press connect the gmail authentication pops up. Nevertheless it fails due to the callback URL being from localhost. Is there any way to get the authentication in place without opening ports in the router?

Welcome to the community @daniello!

For local development with OAuth I always use “localhost” and never had a problem (also just tested again a few minutes ago with GMail). So would be surprised if it would be a problem for you. Can you please describe what exactly is happening and what errors you are seeing. Thanks!

After the last confirmation in the google window I get:

Firefox kann keine Verbindung zu dem Server unter localhost:5678 aufbauen.

n8n is running on a VM in my LAN and I do this from my workplace.

So then you would have to set the Webhook-URL to whatever URL you are currently using to access n8n. Here the documentation:

So if you access n8n currently via http://10.0.0.123:5678/ you would have to set:

export WEBHOOK_TUNNEL_URL="http://10.0.0.123:5678/"

Ah but make also sure to also set in the Google OAuth App to allow this callback URL.

Hmm … I just copied this:
http://localhost:5678/rest/oauth2-credential/callback

and I also tried using my private server IP instead of localhost … which was rejected as an “Autorisierte Weiterleitungs-URIs” … in the Google dasboard.

I dont understand this “export” thing … just following the instructions I find … being a total newbie to this.

What is the URL in your browser if you access n8n?

The “export” thing is setting an environment variable. So depending on if you have n8n npm installed or running via Docker on your VM that would be set differently.

http://192.168.178.116:5678/workflow

In this case, you would have to set WEBHOOK_TUNNEL_URL to http://192.168.178.116:5678/ then it should work fine for OAuth. Be however aware that you will still not be able to use any third-party Trigger nodes as for that your n8n instance has to be web-accessible. So to make that work, you would have to either use the tunnel or install n8n on a server with own domain.

could you reference me to some doc … I have no Idea where to enter that.

I actually already linked the documentation above. You can find everything in there.

There is also a search, so if you search for the “tunnel” you can type it into the search field and it will redirect you here:

If you need the server setup guide it would be this page:

And the webhook configuration here:

I see … thanks … will need some time to digest … potentially I will come the conclusion that I am not developer enough to proceed … thought it may be something as simple as IFTTT.

I made it … it is connected now. If I understood well using the tunnel will let me use n8n with all its modules … great. Google does tell me " “Gmail error response [404]: Requested entity was not found.” … but I assume that has to do with the workflow I tried to throw together as a first test. Will see how I progress.

THANK YOU!

Glad to hear that you got it working! At least more or less.

Honestly is IFTTT now and always will be simpler to use than n8n. It is not our goal to be the most simple solution out there (even though we still want to become simpler than we are right now). We want to be the most powerful one.

2 Likes

maybe you can give me a little heads-up … I would like to trigger something when an incoming gmail mail gets a specific label assigned (by gmail filters). Not sure if it is possilbe to look for a new email with a specific label.

Hey @daniello!

The Gmail node is a regular node and will not trigger the workflow. You will can use the EmailReadImap node. This node will trigger the workflow when you receive a new email.

Hope this helps. :slightly_smiling_face:

@harshil1712
Thank you! … I had expected that I need something else to trigger … like a Cron-Job … but EmailReadImap sounds great. I have more worries about reading the label from the mails. My use case is simply to have a reminder about certain mails coming in which I tend to forget about. So what I usually did was have IFTTT send me an SMS when a mail with label XXX arives in my inbox. SMS won’t be feasible because there are probably only paid services … but once the trigger is in place wil potentially find something in the other adapters :slight_smile:

@harshil1712
I see … the EmailReadImap node should do the trick … all by itself … will do some testing. Great information … thanks again.

1 Like

I am glad I could help. Have fun!

1 Like