skip to navigation
skip to content

django-microsoft-auth 1.0.4

Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.

Django Microsoft Authentication Backend

Simple app to enable Microsoft Account, Office 365 and Xbox Live authentcation as a Django authentcation backend.


  1. Install Django

  2. Install and configure the Sites framework
    • Make sure you update the domain of SITE_ID, this is important and used later. Easy way is to go /admin/sites/site/1/change/ if you have the admin site enabled.
  3. Create a Microsoft OAuth Application
    • write down your client ID
    • Generate an Application Secret, store this somewhere, you will need it for later
    • Add a Web Platform with Allow Implicit Flow and a valid Redirect URL (this will probably be https://<your-domain>/microsoft/auth-callback/), it must be HTTPS
    • Add User.Read under Delegated Permissions
  4. Install package from PyPi:

    pip install django_microsoft_auth
  5. Add the following to your

        # other apps...
            # other template settings...
            'OPTIONS': {
                'context_processors': [
                    # other context_processors...
        'django.contrib.auth.backends.ModelBackend' # if you also want to use Django's authentication
        # I recommend keeping this with at least one database superuser in case of unable to use others
    # pick one
    MICROSOFT_AUTH_LOGIN_TYPE = 'ma'  # Microsoft authentication
    # MICROSOFT_AUTH_LOGIN_TYPE = 'o365'  # Enterprise Office 365 authentication
    # MICROSOFT_AUTH_LOGIN_TYPE = 'xbl'  # Xbox Live authentication
  6. Add the following to your

    urlpatterns = [
        # other urlpatterns...
        url(r'^microsoft/', include('microsoft_auth.urls', namespace='microsoft')),
  7. Run migrations:

    python migrate
  8. Start site and goto /admin to and logout if you are logged in.

  9. Login as Microsoft/Office 365/Xbox Live user. It will fail. This will automatically create your new user.

  10. Login as a Password user with access to change user accounts.

  11. Go to Admin -> Users and edit your Microsoft user to have any permissions you want as you normally.

  12. See microsoft_auth/templates/microsoft/admin_login.html for details examples on making a Login form.

See official docs for more details on setup and configuration.


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


1.0.4 (2017-12-2)

  • Updated Django category to include 2.0

1.0.3 (2017-12-2)

  • Updated for Django 2.0

1.0.2 (2017-11-27)

  • Changed Development Status category to Stable

1.0.0 (2017-11-19)

  • First release on PyPI.
File Type Py Version Uploaded on Size
django_microsoft_auth-1.0.4.tar.gz (md5) Source 2017-12-02 40KB