Problem with Google Calendar OAuth2 API - "This site can’t be reached"

Hello,

I’ve got a problem similar to this one.

I am using a self-hosted version of n8n. It’s a Docker container on a Synology device.

I added OAuth settings on the side of Google according to the instructions, but every time I try to click “Sign In with Google” in n8n, then as soon as I choose an account and click “Allow”, a “This site can’t be reached” error appear.

Does anyone know how to solve this issue?

Thank you in advance :slightly_smiling_face:

Hey @FilipWozniak

Could you confirm that your docker environment’s WEBHOOK_TUNNEL_URL has trailing slash?

For me, it looks like docker config error so have a look at mine, so you can compare:

[simon@mail] /opt/n8n ⇨ cat docker-compose.yml 
version: "3"

services:
  n8n:
      image: n8nio/n8n:0.156.0
      restart: always
      ports:
        - "127.0.0.1:5678:443"
      environment:
        - N8N_BASIC_AUTH_ACTIVE=true
        - N8N_BASIC_AUTH_HASH=true
        - N8N_BASIC_AUTH_USER
        - N8N_BASIC_AUTH_PASSWORD
        - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
        - N8N_PORT=443
        - N8N_PROTOCOL=https
        - NODE_ENV=production
        - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
        - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
        - NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash
        - EXECUTIONS_DATA_PRUNE=true
        - EXECUTIONS_DATA_PRUNE_TIMEOUT=604800
        - DB_SQLITE_VACUUM_ON_STARTUP=true
        - EXECUTIONS_DATA_MAX_AGE=7
        - EXECUTIONS_DATA_SAVE_ON_ERROR=all
        - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
        - EXECUTIONS_DATA_SAVE_ON_PROGRESS=false
        - EXECUTIONS_DATA_SAVE_MANUAL_EXECUTIONS=false
      volumes:
        - /home/${SERVER_USERNAME}/.n8n:/home/node/.n8n
        - /home/${SERVER_USERNAME}/n8n-local-files:/files

[simon@mail] /opt/n8n ⇨ cat .env 
SERVER_USERNAME=simon
DOMAIN_NAME=hryszko.dev
SUBDOMAIN=n8n
N8N_BASIC_AUTH_USER=simon
N8N_BASIC_AUTH_PASSWORD='$2a$10$rm65qlh4PfLStpjmSnWZqumd1e2d1oQ8WyrbHWPnDngyieZS2cxhi'
GENERIC_TIMEZONE=Europe/Berlin
[email protected]

If not you may try to make new app in google console, maybe somewhere there is a problem or at the end try different token type (Service Account or OAuth depended on what you are using now)

Hope you will solve it soon <3

1 Like

It turned out that WEBHOOK_TUNNEL_URL variable wasn’t declared at all - a simple oversight! Sorry.

Anyway, now “Error 400: Invalid Request” occurs :pensive:

I attach below screenshot of environment variables that are set at the moment.

So according to Mozilla docs error 400 is bad request, so google handled the request, but the request was wrong.
Also, error say: device_id and device_name are required for private IP what have make sense for me, since Google has to know that who are you and 127.0.0.1 will be Google itself for them (they will make request to 127.0.0.1 on they’s server, so it’s they’s localhost).
I have never been run n8n on private network, but I made some research and I cannot find how to set those parameters, but you can try to make the fake domain, be aware that this probably will require change, also webhook environment. Have a look at those topics to see how it can be done:

Why 127.0.0.1 won’t work: Login with google return 400 error - #3 by griffinator76 - Self Hosted Redash Support - Redash Discourse

BTW. what is the second screenshot? I am interested.

Hope it will work

1 Like

@Shirobachi second screenshot looks like it migt be portainer.

@FilipWozniak Google can sometimes be a bit funny when you want to use an internal IP for OAUTH, What I tend to do is edit the hosts file on my machine so I can use a domain and my machine will redirect to the correct place.

An alternative would be something like nip.io which is a bit of magic DNS tricky, You could set your webhook_tunnel_url to http://192.168.100.100.nip.io:5678 then update the redirct URI in Google and it should work.

1 Like

What is the second screenshot? I am interested.

Actually, it is a Docker, and more specifically it is a Docker application that you can install from “Package Center” on Synology. In one of the tabs, it allows for editing environment variables.

Also, error say: device_id and device_name are required for private IP what have make sense for me, since Google has to know that who are you and 127.0.0.1 will be Google itself for them (they will make request to 127.0.0.1 on they’s server, so it’s they’s localhost).

Well, actually, I’ve found that, too.

Google can sometimes be a bit funny when you want to use an internal IP for OAuth. What I tend to do is edit the hosts file on my machine so I can use a domain and my machine will redirect to the correct place.

It is not that easy on NAS. I mean, there are plenty of tutorials which demonstrates how to set up DDNS and access the Synology and all applications using address like http://wozniak.synology.me, not a local one (like this one - “How to Access a Synology NAS Remotely with DDNS”), but this requires changing the port forwarding settings and similar. Quite frankly, I don’t want to mess with that. I have a local server for a reason - to be in my local network, and not necessarily be exposed to the whole world.

An alternative would be something like nip.io which is a bit of magic DNS tricky, You could set your webhook_tunnel_url to http://192.168.100.100.nip.io:5678 then update the redirct URI in Google and it should work.

Hmm. I’ve seen a thread on Stack Overflow and someone mentioned something similar - xip.io. I’ll try it.

1 Like

It’s working! :slightly_smiling_face:

Thank you for your help :wink:

2 Likes