Hussa
Hussa

Reputation: 151

How to authenticate in Django with Azure AD via django-microsoft-auth

I'm trying to set up a local Django app which uses Azure Active Directory for authentication. I went through this quick start using the django_microsoft_auth library for backend authentication. I registered a new app on Azure and set the URI to http://localhost:8000/microsoft/auth-callback/. This is the same port which is used for the other pages like the admin page.

When I try to login via Azure AD, I get the following error message:

AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application

Only few other threads with this problem exist and there hasn't been a real solution yet using this library. Does anyone know a solution to this problem?

Upvotes: 2

Views: 6298

Answers (2)

Carl Zhao
Carl Zhao

Reputation: 9511

I have answered similar questions before, and there is a general solution to the problem of not match, which is simple, effective and not easy to make mistakes:

When you visit the application url , you will be redirected to the login page. Decode the authorization request URL, you will find redirect_uri, copy the value of redirect_uri and paste it into the azure portal, and try again.

enter image description here

For the redirect URL, it should start with https, if you need to start with http, you must configure it as http://localhost.

Upvotes: 2

The error message is fairly clear. Your application needs to be registered under your AAD tenant and whatever you enter for the reply URL/Redirect URI in your code needs to match what you have set in the tenant. Please refer to a similar question here.

Upvotes: 2

Related Questions