# Redirect from AzureAD not working

**URL:** <https://discourse.nodered.org/t/redirect-from-azuread-not-working/77108>\
**Category:** General\
**Created:** [31 March 2023 09:33 UTC](https://discourse.nodered.org/t/redirect-from-azuread-not-working/77108 "2023-03-31T09:33:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbahr](https://avatars.discourse-cdn.com/v4/letter/p/87869e/32.png) [@pbahr](https://discourse.nodered.org/u/pbahr)\
**Post date:** [31 March 2023 09:33 UTC](https://discourse.nodered.org/t/redirect-from-azuread-not-working/77108/1 "2023-03-31T09:33:06Z")

</div>

Hey there,

im using the tutorial for azure-ad from here:

> [@Azure AD authentication example](https://discourse.nodered.org/t/azure-ad-authentication-example/40937):
>
> Hello everyone. Today, I wanted to set-up external authentication to my Node-RED instance editor, using the Azure Active Directory of our company. I could not find any guide on this specific task, so after searching around and with a little bit of fiddling I got the integration working. I would like to share the configuration here, so if anyone would like to do the same it could be helpful for them. As described by the [official guide for external security](https://nodered.org/docs/user-guide/runtime/securing-node-red#oauthopenid-based-authentication), Node-RED can use any Passport.js authe…

This is my config:

```auto
  adminAuth: {
    type: "strategy",
    strategy: {
      name: "azuread-openidconnect",
      label: "Sign in with Azure",
      icon: "fa-windows",
      strategy: require("passport-azure-ad").OIDCStrategy,
      options: {
        identityMetadata:
          "https://login.microsoftonline.com/MY_TENANT_ID/v2.0/.well-known/openid-configuration",
        clientID: MY_CLIENT_ID,
        clientSecret: MY_SECRET,
        responseType: "code",
        responseMode: "query",
        redirectUrl: "http://localhost:1880/auth/strategy/callback",
        allowHttpForRedirectUrl: true,
        scope: ["email", "profile"],
        verify: function (profile, done) {
          console.log("Profile: " + profile);
          profile.username = profile._json.preferred_username;
          done(null, profile);
        },
      },
    },
    users: function (user) {
      return Promise.resolve({ username: user, permissions: "*" });
    },
  },

```

But I run into this issue:  
AADSTS50011: The redirect URI '[https://localhost:1880/auth/strategy/callback](https://localhost:1880/auth/strategy/callback)' specified in the request does not match the redirect URIs configured for the application ... Make sure the redirect URI sent in the request matches one added to your application in the Azure portal. Navigate to [Error AADSTS50011 the redirect URI does not match the redirect URIs configured for the application - Active Directory | Microsoft Learn](https://aka.ms/redirectUriMismatchError) to learn more about how to fix this.

Is there something im missing?  
I configured the redirect URL in the Azure-App:

 ![Bildschirm­foto 2023-03-31 um 11.32.28](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/d/cd94ca6a0c084d3cdb94747dd591e75466f125d4.png)

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [31 March 2023 10:23 UTC](https://discourse.nodered.org/t/redirect-from-azuread-not-working/77108/2 "2023-03-31T10:23:42Z")

</div>

In your Node-RED configuration, the callback uri is:

```auto
http://localhost:1880/auth/strategy/callback

```

But in your AD config, you have it set to:

```auto
http://localhost:1880

```

So yes, those two values are different and AD is right to complain.

Update your Azure app's config with the full redirect uri: `http://localhost:1880/auth/strategy/callback`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 April 2023 10:24 UTC](https://discourse.nodered.org/t/redirect-from-azuread-not-working/77108/3 "2023-04-14T10:24:12Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
