Oauth Redirect URL Problem - Microsoft Outlook Oauth2 API

Describe the problem/error/question

I need to make a new Microsoft Outlook Oauth2 API Credential.

I have successfully type-in the client ID and the client secret. I notice that the OAuth Redirect URL pointing at “http://localhost:5678/…” (the default URL for n8n community edition).

I also have configured the Azure App Registrations - Redirect URLs , using my endpoint domain name (Reverse Proxy). In the image below, I change my real domain name with “n8n.mydomainname.com”.

What is the error message (if any)?

I got this error message when I tried to “Connect my account” in the Credential dialog.

I have tried to change the “localhost” using the .env file and/or using the config file, but not working.

Information on your n8n setup

  • **n8n version: 1.98.2
  • **Database (default: SQLite): SQLite
  • **n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • **Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • **Operating system: Win Server 2019

What should I do to solve this problem ?
Thank you.

Hello @bagus88 ,

This error is telling you exactly what’s wrong! The redirect URI you’re using doesn’t match what’s configured in your Azure app registration.

The Problem:

  • Your request is using: http://localhost:5678/rest/oauth2-credential/callback
  • But this URL is not registered in your Azure app’s redirect URIs

How to Fix:

  1. Go to Azure Portal (portal.azure.com)

  2. Navigate to: Azure Active Directory → App registrations → [Your App]

  3. Click on: “Authentication” in the left sidebar

  4. Under “Redirect URIs”:

    • Click “Add a platform”
    • Select “Web”
    • Add this exact URL: http://localhost:5678/rest/oauth2-credential/callback
    • Click “Configure”
  5. Make sure to click “Save” at the top

Thanks @mrrobot for your quick response.

I also have tried to do as you suggested.

I got this error message

For your information, I am accessing the workflow editor (n8n community edition server), using the publish domain name (not using the VM’s).

Looking forward for your kindly response, thank you.

The reason it isn’t working is because it’s local host. You need use a reverse proxy so it can connect with an IP.

@bagus88 ,

Azure apps support localhost redirect uri.

My question is: since you have a domain why use localhost and not setup a tunnel like cloudflare tunnel or a reverse proxy and reference to that your n8n subdomain and not localhost ?

Hi @Grot

Thank you for your reply.

I have use the reverse proxy using Cloudflare tunnel. Therefore I could access the n8n community edition server through my domain name.

The problem is :
I can’t change the OAuth Redirect URL (https://localhost:5678/…) with the "n8n.mydomainname.id (as shown in the address bar of the browser).

The Microsoft Outlook OAuth2 API always displays an error message, either
a. “localhost refused to connect” if I write the exact OAuth Redirect URL in the n8n MS Outlook Credential above in the Microsoft Azure - Platform Configuration - WEB Redirect URLs

b. “The redirect URL, specified in the request does not match the redirect URLs configured for the application.” if I write my n8n domain name in the n8n MS Outlook Credential above in the Microsoft Azure - Platform Configuration - WEB Redirect URLs.

I have tried to change the “localhost:5678” configuration, using the .env file and the config file, still not solving the problem.

Hi @mrrobot

I understand what you mean. I have also used Cloudflare tunnel as a Reverse Proxy.

In the following image, you can see that I have accessed the n8n subdomain using the domain name.

Hey @bagus88 ,

You have to set your
WEBHOOK_URL env correctly to that subdomain