Skip to main content

Microsoft Azure Identity Broker plugin for Python

Project description

Azure Identity Broker plugin for Python

This package extends the Azure Identity library by providing supplemental credentials for authenticating via an authentication broker. An authentication broker is an application that runs on a user's machine that manages the authentication handshakes and token maintenance for connected accounts. The table below outlines supported brokers and the minimum package version required to use each of them.

Broker Minimum package version
Web Account Manager (WAM) on Windows 10+ 1.0.0
Company Portal on macOS 1.3.0b1
Web Account Manager (WAM) on WSL 2.4.13+ 1.3.0b2
Microsoft Identity Broker on Linux 1.3.0b2

Source code | Package (PyPI) | API reference documentation | Microsoft Entra ID documentation

Getting started

Install the package

Install the Azure Identity Broker plugin for Python with pip:

pip install azure-identity-broker

Key concepts

This package enables broker support via InteractiveBrowserBrokerCredential, which is a subclass of the Azure Identity library's InteractiveBrowserCredential.

Parent window handle

When authenticating interactively via InteractiveBrowserBrokerCredential, a parent window handle is required to ensure that the authentication dialog is shown correctly over the requesting window. In the context of graphical user interfaces on devices, a window handle is a unique identifier that the operating system assigns to each window. For the Windows operating system, this handle is an integer value that serves as a reference to a specific window. On macOS, it is an integer-based identifier that represents and identifies a specific window instance.

Microsoft account (MSA) passthrough

Microsoft accounts (MSA) are personal accounts created by users to access Microsoft services. MSA passthrough is a legacy configuration which enables users to get tokens to resources which normally don't accept MSA logins. This feature is only available to first-party applications. Users authenticating with an application that is configured to use MSA passthrough can set enable_msa_passthrough to True inside InteractiveBrowserBrokerCredential to allow these personal accounts to be listed by broker.

Redirect URIs

Microsoft Entra applications rely on redirect URIs to determine where to send the authentication response after a user has logged in. To enable brokered authentication, add a redirect URI to the application for the platform on which it's expected to run.

Platform Redirect URI
Windows 10+ ms-appx-web://Microsoft.AAD.BrokerPlugin/your_client_id
macOS msauth.com.msauth.unsignedapp://auth for unsigned applications
msauth.BUNDLE_ID://auth for signed applications
WSL ms-appx-web://Microsoft.AAD.BrokerPlugin/your_client_id
Linux https://login.microsoftonline.com/common/oauth2/nativeclient

Examples

Authenticate with InteractiveBrowserBrokerCredential

This example demonstrates using InteractiveBrowserBrokerCredential as a broker-enabled credential for authenticating with the BlobServiceClient from the azure-storage-blob library. Here, the win32gui module from the pywin32 package is used to get the current window.

# On Windows
import win32gui
from azure.identity.broker import InteractiveBrowserBrokerCredential
from azure.storage.blob import BlobServiceClient

# Get the handle of the current window
current_window_handle = win32gui.GetForegroundWindow()

credential = InteractiveBrowserBrokerCredential(parent_window_handle=current_window_handle)
client = BlobServiceClient(account_url, credential=credential)

# On macOS
import msal
from azure.identity.broker import InteractiveBrowserBrokerCredential
from azure.storage.blob import BlobServiceClient

credential = InteractiveBrowserBrokerCredential(
    parent_window_handle=msal.PublicClientApplication.CONSOLE_WINDOW_HANDLE
)
client = BlobServiceClient(account_url, credential=credential)

To bypass the account selection dialog and use the default broker account, set the use_default_broker_account argument to True. The credential will attempt to silently use the default broker account. If using the default account fails, the credential will fall back to interactive authentication.

credential = InteractiveBrowserBrokerCredential(
    parent_window_handle=current_window_handle,
    use_default_broker_account=True
)

Troubleshooting

See the Azure Identity troubleshooting guide for details on how to diagnose various failure scenarios.

Next steps

Client library support

Client and management libraries listed on the Azure SDK release page that support Microsoft Entra authentication accept credentials from this library. You can learn more about using these libraries in their documentation, which is linked from the release page.

Known issues

This library doesn't support Azure AD B2C.

For other open issues, refer to the library's GitHub repository.

Provide feedback

If you encounter bugs or have suggestions, open an issue.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

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.

Release History

1.3.0 (2025-08-07)

Features Added

  • Allow silent authentication attempts on all platforms. Previously, use_default_broker_account=True in InteractiveBrowserBrokerCredential only applied to Windows/WSL. (#42375)

1.3.0b2 (2025-07-17)

Features Added

  • Added broker support for Linux and WSL.

Other Changes

  • Python 3.8 is no longer supported. Please use Python version 3.9 or later.

1.3.0b1 (2024-11-05)

Features Added

  • Added broker support for MacOS.

1.2.0 (2024-10-08)

Other Changes

  • Stable release for the Proof-of-Possession (PoP) token support to InteractiveBrowserBrokerCredential.

1.2.0b1 (2024-09-20)

Features Added

  • InteractiveBrowserBrokerCredential now implements the SupportsTokenInfo protocol. It now has a get_token_info method which returns an AccessTokenInfo object. The get_token_info method is an alternative method to get_token that improves support for more complex authentication scenarios.
  • Added Proof-of-Possession (PoP) token support to InteractiveBrowserBrokerCredential.

1.1.0 (2024-04-09)

Features Added

  • InteractiveBrowserBrokerCredential now supports a use_default_broker_account property to enable the use of the currently logged in operating system account for authentication rather than prompting for a credential.
  • Added enable_support_logging as a keyword argument to InteractiveBrowserBrokerCredential. This allows additional support logging which may contain PII.

Other Changes

  • Python 3.7 is no longer supported. Please use Python version 3.8 or later.
  • Bumped minimum dependency on azure-identity to 1.15.0.

1.0.0 (2023-11-07)

Features Added

  • enable_broker is always on if running on Windows. Automatically fall back into non-broker mode if running on MacOS or Linux.

Breaking Changes

  • Removed UsernamePasswordBrokerCredential

1.0.0b1 (2023-10-12)

Features Added

  • Added azure.identity.broker.InteractiveBrowserBrokerCredential and azure.identity.broker.UsernamePasswordBrokerCredential which have broker support.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure_identity_broker-1.3.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azure_identity_broker-1.3.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file azure_identity_broker-1.3.0.tar.gz.

File metadata

  • Download URL: azure_identity_broker-1.3.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: RestSharp/106.13.0.0

File hashes

Hashes for azure_identity_broker-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1f40ea42d31da86669fe4cd4f93e4cdf91b9b1cffca1fba39cf5ba0f7df1bd27
MD5 af7ee0c203c5d922bed007e7b76c8ef1
BLAKE2b-256 01caa8eb8571f71f244a07debc77f335deadee6ecb17be5743479f878a68eaa4

See more details on using hashes here.

File details

Details for the file azure_identity_broker-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for azure_identity_broker-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1e17b9a48378ea32180ba428eb2eca8b29eda93310d7123beb246ae94306d8c0
MD5 f551e5884d74a6034f49491924c84ab3
BLAKE2b-256 faf9b3bd9b1c3d692404bedeec27aeb596d1984b1a99c6513e90e5f68cb95726

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page