msal 1.36.0


pip install msal

  Latest version

Released: Apr 09, 2026


Meta
Author: Microsoft Corporation
Requires Python: >=3.8

Classifiers

Development Status
  • 5 - Production/Stable

Programming Language
  • Python
  • Python :: 3 :: Only
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Microsoft Authentication Library (MSAL) for Python

dev branch Reference Docs # of Downloads per different platforms # of Downloads per recent MSAL versions Benchmark Diagram
Build status Documentation Status Downloads Download monthly ๐Ÿ“‰

The Microsoft Authentication Library for Python enables applications to integrate with the Microsoft identity platform. It allows you to sign in users or apps with Microsoft identities (Microsoft Entra ID, External identities, Microsoft Accounts and Azure AD B2C accounts) and obtain tokens to call Microsoft APIs such as Microsoft Graph or your own APIs registered with the Microsoft identity platform. It is built using industry standard OAuth2 and OpenID Connect protocols

Not sure whether this is the SDK you are looking for your app? There are other Microsoft Identity SDKs here.

Quick links:

Getting Started Docs Samples Support Feedback

Scenarios supported

Click on the following thumbnail to visit a large map with clickable links to proper samples.

Map effect won't work inside github's markdown file, so we have to use a thumbnail here to lure audience to a real static website

Installation

You can find MSAL Python on Pypi.

  1. If you haven't already, install and/or upgrade the pip of your Python environment to a recent version. We tested with pip 18.1.
  2. As usual, just run pip install msal.

Versions

This library follows Semantic Versioning.

You can find the changes for each version under Releases.

Usage

Before using MSAL Python (or any MSAL SDKs, for that matter), you will have to register your application with the Microsoft identity platform.

Acquiring tokens with MSAL Python follows this 3-step pattern. (Note: That is the high level conceptual pattern. There will be some variations for different flows. They are demonstrated in runnable samples hosted right in this repo. )

  1. MSAL proposes a clean separation between public client applications, and confidential client applications. So you will first create either a PublicClientApplication or a ConfidentialClientApplication instance, and ideally reuse it during the lifecycle of your app. The following example shows a PublicClientApplication:

    from msal import PublicClientApplication
    app = PublicClientApplication(
        "your_client_id",
        authority="https://login.microsoftonline.com/Enter_the_Tenant_Name_Here")
    

    Later, each time you would want an access token, you start by:

    result = None  # It is just an initial value. Please follow instructions below.
    
  2. The API model in MSAL provides you explicit control on how to utilize token cache. This cache part is technically optional, but we highly recommend you to harness the power of MSAL cache. It will automatically handle the token refresh for you.

    # We now check the cache to see
    # whether we already have some accounts that the end user already used to sign in before.
    accounts = app.get_accounts()
    if accounts:
        # If so, you could then somehow display these accounts and let end user choose
        print("Pick the account you want to use to proceed:")
        for a in accounts:
            print(a["username"])
        # Assuming the end user chose this one
        chosen = accounts[0]
        # Now let's try to find a token in cache for this account
        result = app.acquire_token_silent(["your_scope"], account=chosen)
    
  3. Either there is no suitable token in the cache, or you chose to skip the previous step, now it is time to actually send a request to AAD to obtain a token. There are different methods based on your client type and scenario. Here we demonstrate a placeholder flow.

    if not result:
        # So no suitable token exists in cache. Let's get a new one from AAD.
        result = app.acquire_token_by_one_of_the_actual_method(..., scopes=["User.Read"])
    if "access_token" in result:
        print(result["access_token"])  # Yay!
    else:
        print(result.get("error"))
        print(result.get("error_description"))
        print(result.get("correlation_id"))  # You may need this when reporting a bug
    

Refer the Wiki pages for more details on the MSAL Python functionality and usage.

Migrating from ADAL

If your application is using ADAL Python, we recommend you to update to use MSAL Python. No new feature work will be done in ADAL Python.

See the ADAL to MSAL migration guide.

Roadmap

You can follow the latest updates and plans for MSAL Python in the Roadmap published on our Wiki.

Samples and Documentation

MSAL Python supports multiple application types and authentication scenarios. The generic documents on Auth Scenarios and Auth protocols are recommended reading.

We provide a full suite of sample applications and documentation to help you get started with learning the Microsoft identity platform.

Community Help and Support

We leverage Stack Overflow to work with the community on supporting Microsoft Entra and its SDKs, including this one! We highly recommend you ask your questions on Stack Overflow (we're all on there!) Also browser existing issues to see if someone has had your question before.

We recommend you use the "msal" tag so we can see it! Here is the latest Q&A on Stack Overflow for MSAL: http://stackoverflow.com/questions/tagged/msal

Submit Feedback

We'd like your thoughts on this library. Please complete this short survey.

Security Reporting

If you find a security issue with our libraries or services please report it to secure@microsoft.com with as much detail as possible. Your submission may be eligible for a bounty through the Microsoft Bounty program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting this page and subscribing to Security Advisory Alerts.

Contributing

All code is licensed under the MIT license and we triage actively on GitHub. We enthusiastically welcome contributions and feedback. Please read the contributing guide before starting.

We Value and Adhere to the Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

1.36.0 Apr 09, 2026
1.35.1 Mar 04, 2026
1.35.0 Feb 24, 2026
1.35.0b1 Jan 06, 2026
1.34.0 Sep 22, 2025
1.34.0b1 Aug 12, 2025
1.33.0 Jul 22, 2025
1.33.0b1 Jun 05, 2025
1.32.3 Apr 25, 2025
1.32.2 Apr 25, 2025
1.32.1 Apr 24, 2025
1.32.0 Mar 12, 2025
1.31.2b1 Jan 28, 2025
1.31.1 Nov 18, 2024
1.31.0 Sep 06, 2024
1.30.0 Jul 17, 2024
1.29.0 Jun 22, 2024
1.28.1 Jun 11, 2024
1.28.0 Mar 19, 2024
1.27.0 Feb 22, 2024
1.27.0b2 Dec 09, 2023
1.26.0 Dec 05, 2023
1.25.0 Nov 04, 2023
1.24.1 Sep 29, 2023
1.24.0 Sep 12, 2023
1.24.0b2 Sep 19, 2023
1.24.0b1 Jul 24, 2023
1.23.0 Jul 22, 2023
1.22.0 Apr 17, 2023
1.21.0 Jan 31, 2023
1.20.0 Oct 07, 2022
1.20.0b1 Aug 29, 2022
1.19.0 Sep 21, 2022
1.18.0 May 31, 2022
1.18.0b1 May 19, 2022
1.17.0 Feb 11, 2022
1.16.0 Oct 29, 2021
1.15.0 Oct 01, 2021
1.14.0 Aug 26, 2021
1.13.0 Jul 20, 2021
1.12.0 May 19, 2021
1.11.0 Apr 09, 2021
1.10.0 Mar 08, 2021
1.9.0 Feb 09, 2021
1.8.0 Dec 16, 2020
1.7.0 Dec 07, 2020
1.6.0 Nov 02, 2020
1.5.1 Oct 21, 2020
1.5.0 Sep 03, 2020
1.4.3 Jul 25, 2020
1.4.2 Jul 23, 2020
1.4.1 Jun 26, 2020
1.4.0 Jun 25, 2020
1.3.0 May 15, 2020
1.2.0 Mar 31, 2020
1.1.0 Jan 23, 2020
1.0.0 Nov 01, 2019
0.9.0 Oct 31, 2019
0.8.0 Oct 19, 2019
0.7.0 Sep 25, 2019
0.6.1 Aug 13, 2019
0.6.0 Jul 31, 2019
0.5.1 Jul 10, 2019
0.5.0 Jul 08, 2019
0.4.1 Jun 18, 2019
0.4.0 May 22, 2019
0.3.1 Apr 17, 2019
0.3.0 Apr 02, 2019
0.2.0 Mar 05, 2019
0.1.0 Dec 12, 2018

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
requests (<3,>=2.0.0)
PyJWT[crypto] (<3,>=1.0.0)
cryptography (<49,>=2.5)