User Profile
pawan243
Copper Contributor
Joined 2 years ago
User Widgets
Recent Discussions
Django-microsoft authentication Failure!!!
Hi, 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 settings.py 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 #settings.py LOGIN_REDIRECT_URL = 'http://localhost:8000/accounts/microsoft/login/callback/' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.microsoft' ] # Set the authentication backend AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ] SOCIALACCOUNT_PROVIDERS = { 'microsoft': { 'APP': { 'client_id': '<id>' 'secret': '<secret>', } }, } #urls.py from django.contrib import admin from django.urls import path, include from . import views from allauth.account.views import LoginView urlpatterns = [ path('admin/', admin.site.urls), path('', views.home, name='home'), path('accounts/', include('allauth.urls')), # path('accounts/microsoft/login/', LoginView.as_view(), name='microsoft_login'), ] #views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): return render(request, 'index.html') #index.html <body> <div class="container"> <h1>Login</h1> <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"> </form> {% load account %} {% load socialaccount %} <a href="{% url 'microsoft_login' %}">Login with Microsoft</a> </div> </body> All I have shared the code for microsoft login that i have used to configure. Kindly help me to sort this out. Regards, Pawan2KViews0likes2Comments
Groups
Recent Blog Articles
No content to show