Keep showing unauthorized when connect LinkedIn to my self-hosted server

Describe the problem/error/question

setting up linked in post node in my self-host n8n keep failing, i have configure client id, client secret, add callback url,
disabled organization and legacy,
when i press connect, it opens the linked in login page correctly, after approving i keep getting this error page Error: Unauthorized,

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: v2.29.5
  • Database (default: SQLite): postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Truenas
  • Operating system: Linux

Hi @rick

You cannot use a raw http://192.168... address for LinkedIn. You have three main options:

  • Reverse Proxy (Recommended): Use Nginx Proxy Manager​, Traefik​, or Caddy (all available as apps on TrueNAS) to map a domain (e.g., n8n.yourdomain.com) to your local IP and generate a free SSL certificate via Let’s Encrypt.
  • Cloudflare Tunnel: If you don’t want to open ports on your router, use a Cloudflare Tunnel (cloudflared). This provides a secure https URL that points directly to your TrueNAS instance.
  • Tailscale Funnel: If you use Tailscale, you can use “Funnel” to expose your local n8n instance via a secure HTTPS address.

Once you have an HTTPS address, you must tell n8n to use it for all OAuth callbacks. In your TrueNAS/Docker environment variables, add or update:

  • Key: WEBHOOK_URL
  • Value: https://n8n.yourdomain.com/ (Replace with your actual secure URL)

Restart your n8n container after changing this variable.

Then go back to the LinkedIn Developer Portal:

  1. Go to the Auth tab.
  2. Under OAuth 2.0 redirect URIs​, remove the http://192.168... address.
  3. Add your new secure address: https://n8n.yourdomain.com/rest/oauth2-credential/callback

Does that help?

@rick can you expand the more details if possible it may show us more info, I suspect the issue might be that you don’t have the correct “products” enabled on the LinkedIn side.

i provided the screenshot, as you can see i enabled producs of “share on linkedIn” and “sign in with LinkedIn using OpenID Connect”

Ah ok, make sense, thanks for the guide, i will give it a shot to setup HTTPS for it

@rick in the screenshot where is says auth failed there is some text that says More Details, if you click that it should expand with some more details

@rick

One thing to add if you go the Cloudflare Tunnel route, since it bit me and the symptom looks exactly like this "Unauthorized" screen even after HTTPS is working.

If you put the tunnel behind Cloudflare Access (a login screen in front of n8n), Access also challenges the OAuth callback path, and LinkedIn's popup cannot log in through that challenge. So the ?code= never reaches n8n and you get "Error: Unauthorized, the window can be closed now."

Two things to check once you are on an https URL:

  1. Set WEBHOOK_URL (and N8N_EDITOR_BASE_URL if you use it) to the exact public https host, then restart the container. The redirect has to land on the same host the login started on, or the session and the OAuth state will not match and you get Unauthorized. A raw 192.168 IP fails for that reason too, on top of LinkedIn refusing a private http address.
  2. If you use Cloudflare Access, add a bypass for /rest/oauth2-credential/* (a policy with "everyone", or a service token) so Access does not intercept the callback. On a plain Cloudflare Tunnel with no Access policy, you can skip this.

And the redirect URL you register in LinkedIn's Auth tab is the full path, exact match and https: https://your-host/rest/oauth2-credential/callback.