Azure Identity Broker Plugin
raw JSON → 1.3.0 verified Fri May 01 auth: no python
A Microsoft Authentication Extensions (WAM) broker plugin for Azure Identity, enabling interactive authentication with Web Account Manager on Windows. Current version 1.3.0, requires Python >=3.9. Released as part of the Azure SDK for Python.
pip install azure-identity-broker Common errors
error ModuleNotFoundError: No module named 'azure.identity.broker' ↓
cause Missing or outdated azure-identity-broker package, or incorrect import path.
fix
Run 'pip install azure-identity-broker' and ensure you use 'from azure.identity.broker import InteractiveBrowserBrokerCredential'.
error RuntimeError: Broker authentication is not supported on this platform. Use WAM on Windows. ↓
cause Running on a non-Windows OS (Linux, macOS) where Web Account Manager is not available.
fix
Use AzureCliCredential, DefaultAzureCredential, or InteractiveBrowserCredential instead.
error ValueError: parent_window_handle is required for broker authentication ↓
cause The credential constructor requires parent_window_handle; it was omitted or set to None incorrectly.
fix
Provide a valid HWND (integer) or pass parent_window_handle=None if you don't have a parent window.
Warnings
gotcha Broker is only supported on Windows (Web Account Manager). On Linux or macOS, InteractiveBrowserBrokerCredential will raise a RuntimeError. ↓
fix Use DefaultAzureCredential or InteractiveBrowserCredential for cross-platform support.
gotcha parent_window_handle must be a valid HWND (integer) on Windows, or None. Omitting it or passing an invalid handle may cause the broker UI to not appear properly. ↓
fix If running in a GUI application, obtain the HWND of the parent window and pass it as parent_window_handle.
deprecated The azure.identity.broker module was introduced to separate broker-specific credential from azure-identity. Previous version (0.x) had this credential in the main azure.identity package. ↓
fix Use from azure.identity.broker import InteractiveBrowserBrokerCredential for version 1.x.
Imports
- InteractiveBrowserBrokerCredential wrong
from azure.identity import InteractiveBrowserBrokerCredentialcorrectfrom azure.identity.broker import InteractiveBrowserBrokerCredential
Quickstart
import os
from azure.identity.broker import InteractiveBrowserBrokerCredential
credential = InteractiveBrowserBrokerCredential(
client_id=os.environ.get("AZURE_CLIENT_ID", ""),
tenant_id=os.environ.get("AZURE_TENANT_ID", ""),
parent_window_handle=None # Set to a Windows HWND for UI parent
)
token = credential.get_token("https://graph.microsoft.com/.default")
print(token.token)