Unauthorized error when connecting Facebook Lead Ads account

Describe the problem/error/question

Hi. I’m trying to connect the Facebook Lead Ads account (the only element in my workflow so far is a Facebook Lead Ads Trigger) to transfer leads to my CRM. To set up the account, I already did and double-checked:

  • Created the app in Meta
  • Added (correct) callback URL from n8n
  • Obtained advanced access for public_profile
  • Did verification, etc., that is necessary to take the app live and set it to “live”
  • Verified that pages_manage_metadata, pages_read_engagement, pages_show_list and leads_retrieval are “ready” for standard level
  • Added App ID and Secret to n8n
  • Clicked on Connect and selected everything
  • At the end of that Meta-Dialogue, it says that the app was connected and I can manage the connection via Facebook business apps. When I click on the final confirmation button, it opens the n8n callback URL with a “?code=…” attached to it. And there I see a simple JSON unauthorized error (see below)

I also tried to delete the account from n8n completely and remove the connection from the Facebook Business Apps to start fresh, but I get the same result.

Can anyone please give me a hint where I went wrong?

Thanks a lot.

Michael

What is the error message (if any)?

{“status”:“error”,“message”:“Unauthorized”}

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

instance information

Debug info

core

  • n8nVersion: 2.13.4
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.13.1
  • nodeEnv: production
  • database: postgres
  • executionMode: scaling (single-main)
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: b14dff60-0166-47d7-95ff-2e9187c3efcb

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: database

pruning

  • enabled: true
  • maxAge: 168 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/146.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2026-03-30T15:22:14.796Z

the unauthorized at the callback is almost always a redirect URI mismatch between what n8n sends and what you registered in Meta. for self-hosted docker the key env var is N8N_EDITOR_BASE_URL — if its not set or doesn’t match exactly (including http vs https and any trailing slashes), the oauth exchange fails silently. id compare your meta app settings side by side with what n8n is actually using, that fixed it for us when we hit this with a custom docker setup.

Id double check that N8N_EDITOR_BASE_URL and WEBHOOK_URL in your docker config match exactly what you put as the callback in Meta, even a missing trailing slash or http vs https will break the oauth exchange silently.