Django-microsoft authentication Failure!!!

Copper Contributor



I have created a demo app using django and wanted to integrate microsoft social authentication with app but unable to complete the login authentication process successfully.


I have registered the app on Azure AD as a "Personal Microsoft accounts only" and got the Client Id and Client Secret and configured the same in my of django app.


But I am getting this below error after putting login credentials while MS login on the app.

Please refer to error screenshot.



Here is the configuration details microsoft login



LOGIN_REDIRECT_URL = 'http://localhost:8000/accounts/microsoft/login/callback/'

# Application definition


# Set the authentication backend
    'microsoft': {
        'APP': {
            'client_id': '<id>'
            'secret': '<secret>',


from django.contrib import admin
from django.urls import path, include
from . import views
from allauth.account.views import LoginView

urlpatterns = [
    path('', views.home, name='home'),
    path('accounts/', include('allauth.urls')),
    # path('accounts/microsoft/login/', LoginView.as_view(), name='microsoft_login'),


from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.

def home(request):
    return render(request, 'index.html')





    <div class="container">
        <form method="POST" action="/login">
            <!-- {% csrf_token %} -->
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
            <input type="submit" value="Login">
        {% load account %}
        {% load socialaccount %}
        <a href="{% url 'microsoft_login' %}">Login with Microsoft</a>





All I have shared the code for microsoft login that i have used to configure.


Kindly help me to sort this out.




0 Replies