OAuth Authorization Error - GitHub OAuth2 API Credential

Hey there,

I’m having an issue with connecting to a GitHub OAuth2 API Credential after updating to the latest version of n8n (I’m not sure what version I was on before, but it was a couple months old).

When clicking “Connect my account”, I get the following error:

OAuth Authorization Error
There was a problem generating the authorization URL
Cannot read properties of undefined (reading ‘globalRole’)

I’ve tried creating a new OAuth app on GitHub, but that didn’t help.

My docker-compose file is as follows:

version: "3"

services:
  n8n:
    image: n8nio/n8n
    container_name: n8n
    restart: always
    ports:
      - 127.0.0.1:8003:5678
    volumes:
      - /home/adam/apps/n8n/data/:/home/node/.n8n/
    environment:
      - WEBHOOK_URL=https://n8n.${domain}

I’m serving my n8n instance behind a reverse proxy. I’m not sure if this is related to the issue. I had no issues before and everything was the same.

1 Like

I had the same problem with Microsoft Teams OAuth2 API:

version: "3"

services:
 traefik:
  image: traefik
  container_name: "traefik_n8n"
  restart: always
  command:
   - "--api=true"
   - "--api.insecure=true"
   - "--providers.docker=true"
   - "--providers.docker.exposedbydefault=false"
   - "--entrypoints.web.address=:80"
   - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
   - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
   - "--entrypoints.websecure.address=:443"
   - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
   #- "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
   - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - ${DATA_FOLDER}/letsencrypt:/letsencrypt
    - /var/run/docker.sock:/var/run/docker.sock:ro


 n8n:
  image: n8nio/n8n
  container_name: "n8n_app"
  restart: always
  ports:
   - "5678:5678"
  labels:
   - traefik.enable=true
   - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
   - traefik.http.routers.n8n.tls=true
   - traefik.http.routers.n8n.entrypoints=web,websecure
   - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
   - traefik.http.middlewares.n8n.headers.SSLRedirect=true
   - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
   - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
   - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
   - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
   - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
   - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
   - traefik.http.middlewares.n8n.headers.STSPreload=true
  environment:
   - N8N_BASIC_AUTH_HASH=true
   - N8N_BASIC_AUTH_ACTIVE=true
   - N8N_BASIC_AUTH_USER
   - N8N_BASIC_AUTH_PASSWORD
   - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
   - N8N_PORT=5678
   - N8N_PROTOCOL=https
   - NODE_ENV=production
   - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
   - HTTP_PROXY=${PROXY_CONFIGURATION}
   - HTTPS_PROXY=${PROXY_CONFIGURATION}
   - NO_PROXY=${NOPROXY_CONFIGURATION}
   - N8N_USE_DEPRECATED_REQUEST_LIB=true
   - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
  volumes:
   - ${DATA_FOLDER}/.n8n:/home/node/.n8n

Hey @iamoshiro,

Do you have the same error message?

Yes, that’s the same error. Yesterday I was testing and that didn’t happen, the problem had begin when I updated the n8n docker image. I’ll test to see if the error is in the other server…I’ll return soon.

The problem continue in the other server too…I also tried remove traefik, proxy configuration, WEBHOOK_URL and N8N_USE_DEPRECATED_REQUEST_LIB without sucessfull.

Hey @iamoshiro & @adamhl8,

I have managed to reproduce the same issue here using the Github oauth option, It looks like the twitter oauth process is ok so this will need some more digging.

Just to help…I tested with a non-official docker image (crazymax/n8n) and the Microsoft OAuth2 authentication worked!

From what I can see that version is running on 133 which is really old now, I suspect this change has something to do with the new user management feature but we will need to dig into it more.

Yep I noted that too. Is it possible to available the old image version in docker hub?

The older images should be there you would just need to pull n8n:whatever-version and you are good to go.

Oh right, thanks for your help.

Quick update for you both, This has now been fixed in this PR: Fix issue with n8n not authenticating oauth requests by krynble · Pull Request #2998 · n8n-io/n8n · GitHub so this should be released shortly.

1 Like

Sounds great, thanks @Jon. I rollback to version 0.167.0, I noted that have a new version 0.168.2 but I can’t updated yet…I’ll try late. Thanks for your help.

Hey @iamoshiro,

That 168.2 version would be the one to use, The docker images look like they are still building shouldn’t be too much longer :slight_smile:

Docker image is now ready.

2 Likes

Pulled the newest image and everything works as expected now. Thanks!

1 Like

@Jon @jan I am also facing the same problem with the OAuth redirect with zendesk
it works on previous versions (0.167.0) but not the new ones (0.168.2 or 0.169.0)

Working docker image:

docker run -it --rm \
        --name n8n \
        -p 5678:5678 \
        -v ~/.n8n:/home/node/.n8n \
        -e N8N_BASIC_AUTH_ACTIVE=true\
        -e N8N_BASIC_AUTH_USER=hasan\
        -e N8N_BASIC_AUTH_PASSWORD=hasan\
        -e N8N_AUTH_EXCLUDE_ENDPOINTS="rest/oauth2-credential/callback" \
      n8nio/n8n:0.167.0

Failing OAuth docker image

docker run -it --rm \
        --name n8n \
        -p 5678:5678 \
        -v ~/.n8n:/home/node/.n8n \
        -e N8N_BASIC_AUTH_ACTIVE=true\
        -e N8N_BASIC_AUTH_USER=hasan\
        -e N8N_BASIC_AUTH_PASSWORD=hasan\
        -e N8N_AUTH_EXCLUDE_ENDPOINTS="rest/oauth2-credential/callback" \
      n8nio/n8n:0.169.0

Is there a plan to fix this or a workaround for this?

Hey @hasanhw,

Welcome to the community :cake:

It might be worth opening a new thread for this one as the issue for the Github node has been resolved. Are you also able to share the error you are getting? A quick test using the same method that failed for the Github node before appears to be working for me here.

Hi @Jon Thanks for the welcome!
I opened a new topic here

1 Like