The Azure Identity library provides Microsoft Entra ID token-based authentication support across the Azure SDK. It provides a set of TokenCredential/SupportsTokenInfo implementations, which can be used to construct Azure SDK clients that support Microsoft Entra token authentication.
Python 3.10 or a recent version of Python 3 (this library doesn't support end-of-life versions)
Use with AI tools
AI coding tools such as VS Code and GitHub Copilot can help you write and debug code that uses this library. See Using the Azure SDK for Python with AI tools for available integrations.
Authenticate the client
When debugging and executing code locally, it's typical for a developer to use their own account for authenticating calls to Azure services. There are several developer tools that can be used to perform this authentication in your development environment. For more information, see Authentication during local development.
Key concepts
Credentials
A credential is a class that contains or can obtain the data needed for a service client to authenticate requests. Service clients across the Azure SDK accept a credential instance when they're constructed, and use that credential to authenticate requests.
The Azure Identity library focuses on OAuth authentication with Microsoft Entra ID. It offers various credential classes capable of acquiring a Microsoft Entra access token. See the Credential classes section for a list of this library's credential classes.
DefaultAzureCredential
DefaultAzureCredential simplifies authentication while developing apps that deploy to Azure by combining credentials used in Azure hosting environments with credentials used in local development. For more information, see DefaultAzureCredential overview.
Continuation policy
As of version 1.14.0, DefaultAzureCredential attempts to authenticate with all developer credentials until one succeeds, regardless of any errors previous developer credentials experienced. For example, a developer credential may attempt to get a token and fail, so DefaultAzureCredential will continue to the next credential in the flow. Deployed service credentials stop the flow with a thrown exception if they're able to attempt token retrieval, but don't receive one. Prior to version 1.14.0, developer credentials would similarly stop the authentication flow if token retrieval failed, but this is no longer the case.
This allows for trying all of the developer credentials on your machine while having predictable deployed behavior.
Define a custom authentication flow with ChainedTokenCredential
While DefaultAzureCredential is generally the quickest way to authenticate apps for Azure, you can create a customized chain of credentials to be considered. ChainedTokenCredential enables users to combine multiple credential instances to define a customized chain of credentials. For more information, see ChainedTokenCredential overview.
Async credentials
This library includes a set of async APIs. To use the async credentials in azure.identity.aio, you must first install an async transport, such as aiohttp. For more information, see azure-core documentation.
Async credentials should be closed when they're no longer needed. Each async credential is an async context manager and defines an async close method. For example:
from azure.identity.aio import DefaultAzureCredential
# call close when the credential is no longer needed
credential = DefaultAzureCredential()
...
await credential.close()
# alternatively, use the credential as an async context manager
credential = DefaultAzureCredential()
async with credential:
...
This example demonstrates authenticating the asynchronous SecretClient from azure-keyvault-secrets with an asynchronous credential.
from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.secrets.aio import SecretClient
default_credential = DefaultAzureCredential()
client = SecretClient("https://my-vault.vault.azure.net", default_credential)
Managed identity support
Managed identity authentication is supported either indirectly via DefaultAzureCredential or directly via ManagedIdentityCredential for the following Azure services:
After configuring an identity binding and authorizing the pod's Kubernetes service account, construct WorkloadIdentityCredential directly with enable_azure_proxy=True:
from azure.identity import WorkloadIdentityCredential
with WorkloadIdentityCredential(enable_azure_proxy=True) as credential:
token = credential.get_token("https://management.azure.com/.default")
AKS supplies the pod's identity, projected-token, proxy, SNI, and CA configuration. Identity binding mode isn't supported through DefaultAzureCredential. The asynchronous WorkloadIdentityCredential in azure.identity.aio supports the same option.
Cloud configuration
Credentials default to authenticating to the Microsoft Entra endpoint for Azure Public Cloud. To access resources in other clouds, such as Azure Government or a private cloud, configure credentials with the authority argument. AzureAuthorityHosts defines authorities for well-known clouds:
from azure.identity import AzureAuthorityHosts
DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)
If the authority for your cloud isn't listed in AzureAuthorityHosts, you can explicitly specify its URL:
As an alternative to specifying the authority argument, you can also set the AZURE_AUTHORITY_HOST environment variable to the URL of your cloud's authority. This approach is useful when configuring multiple credentials to authenticate to the same cloud:
Not all credentials require this configuration. Credentials that authenticate through a development tool, such as AzureCliCredential, use that tool's configuration.
path to a PEM or PKCS12 certificate file including private key
X
AZURE_CLIENT_CERTIFICATE_PASSWORD
password of the certificate file, if any
AZURE_CLIENT_SEND_CERTIFICATE_CHAIN
If True, the credential sends the public certificate chain in the x5c header of each token request's JWT. This is required for Subject Name/Issuer (SNI) authentication. Defaults to False. There's a known limitation that async SNI authentication isn't supported.
Configuration is attempted in the preceding order. For example, if values for a client secret and certificate are both present, the client secret is used.
Continuous Access Evaluation
As of version 1.14.0, accessing resources protected by Continuous Access Evaluation (CAE) is possible on a per-request basis. This behavior can be enabled by setting the enable_cae keyword argument to True in the credential's get_token method. CAE isn't supported for developer and managed identity credentials.
Token caching
Token caching is a feature provided by the Azure Identity library that allows apps to:
Cache tokens in memory (default) or on disk (opt-in).
Improve resilience and performance.
Reduce the number of requests made to Microsoft Entra ID to obtain access tokens.
The Azure Identity library offers both in-memory and persistent disk caching. For more information, see the token caching documentation.
Brokered authentication
An authentication broker is an application that runs on a user’s machine and manages the authentication handshakes and token maintenance for connected accounts. Currently, only the Windows Web Account Manager (WAM) is supported. Authentication via WAM is used by DefaultAzureCredential to enable secure sign-in. To enable support, use the azure-identity-broker package. For details on authenticating using WAM, see the broker plugin documentation.
Troubleshooting
See the troubleshooting guide for details on how to diagnose various failure scenarios.
Error handling
Credentials raise CredentialUnavailableError when they're unable to attempt authentication because they lack required data or state. For example, EnvironmentCredential raises this exception when its configuration is incomplete.
Credentials raise azure.core.exceptions.ClientAuthenticationError when they fail to authenticate. ClientAuthenticationError has a message attribute, which describes why authentication failed. When raised by DefaultAzureCredential or ChainedTokenCredential, the message collects error messages from each credential in the chain.
For more information on handling specific Microsoft Entra ID errors, see the Microsoft Entra ID error code documentation.
Logging
This library uses the standard logging library for logging. Credentials log basic information, including HTTP sessions (URLs, headers, etc.) at INFO level. These log entries don't contain authentication secrets.
Detailed DEBUG-level logging, including request/response bodies and header values, isn't enabled by default. It can be enabled with the logging_enable argument. For example:
CAUTION: DEBUG-level logs from credentials contain sensitive information.
These logs must be protected to avoid compromising account security.
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.
If you encounter bugs or have suggestions, open an issue.
Contributing
For deeper context on why the library is designed the way it is, see the architecture decision log, a chronological record of key design decisions and the reasoning behind them.
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'll only need to do this once across all repos using our CLA.
Added support for WorkloadIdentityCredential identity binding mode in AKS environments. This feature uses an AKS proxy to handle FIC exchanges on behalf of pods, addressing Entra's limit on federated identity credentials per managed identity. Enable it by constructing WorkloadIdentityCredential directly with enable_azure_proxy=True. Identity binding mode isn't supported through DefaultAzureCredential. (#43287, #44147)
Bugs Fixed
Fixed AzureDeveloperCliCredential to correctly parse error messages from Azure Developer CLI v1.23.7 and later, which previously caused raw JSON to surface in ClientAuthenticationError instead of the underlying error text. (#46711)
Fixed persistent token cache isolation on macOS when using custom cache names or CAE-enabled caches. (#49314)
Fixed a regression in 1.26.0 where asynchronous OnBehalfOfCredential instances could not reuse access or refresh tokens cached by another instance with the same user assertion. Cache entries are now isolated by user assertion, allowing safe reuse across instances, including with TokenCachePersistenceOptions. Existing cache entries without assertion binding require a fresh token exchange. (#49533)
1.26.0 (2026-09-30)
Features Added
ManagedIdentityCredential now supports user-assigned managed identities on Azure Arc-enabled servers. An identity can be selected by client ID, object ID, or resource ID. Token responses that do not confirm the requested identity are rejected. (#48967)
Bugs Fixed
Fixed synchronous Service Fabric managed identity authentication with MSAL 1.39.0 and later. Service Fabric now uses the session from an Azure Core RequestsTransport. (#48967)
Fixed an issue where AuthorizationCodeCredential and the asynchronous OnBehalfOfCredential could return a cached token for another account when multiple credentials shared a token cache. (#49001)
Other Changes
Added RequestIdPolicy to the default pipeline policies to ensure a unique x-ms-client-request-id header is sent with each request. (#46070)
CertificateCredential now passes the PEM private key to MSAL as a str rather than bytes, matching MSAL's documented client_credential contract. (#46801)
Bumped the minimum dependency on msal to >=1.39.0.
1.25.3 (2026-03-12)
Bugs Fixed
Fixed an issue where an expired token could skip refresh when a recent token request was made, due to the retry delay taking precedence over expiration. (#45496)
Other Changes
Bumped minimum dependency on msal to >=1.35.1.
1.26.0b2 (2026-02-11)
Breaking Changes
These changes do not impact the API of stable versions such as 1.25.2.
Only code written against beta version 1.26.0b1 is affected.
Renamed use_token_proxy keyword argument to enable_azure_proxy in WorkloadIdentityCredential to better reflect its purpose. (#44147)
1.25.2 (2026-02-10)
Bugs Fixed
Fixed an issue with certain credentials not bypassing the token cache when claims are provided in get_token or get_token_info calls. (#44552) (#44815)
Fixed an issue where an unhelpful TypeError was raised during Entra ID token requests that returned empty responses. Now, a ClientAuthenticationError is raised with the full response for better troubleshooting. (#44258)
Other Changes
Bumped minimum dependency on msal to >=1.31.0.
Added debug logging of access token cache hits in several credentials to improve troubleshooting of token cache behavior. (#44963)
Replace instances of azure.core.pipeline.transport.HttpRequest with azure.core.rest.HttpRequest. (#44993)
1.26.0b1 (2025-11-07)
Features Added
Added support for WorkloadIdentityCredential identity binding mode in AKS environments. This feature addresses Entra's limitation on the number of federated identity credentials (FICs) per managed identity by utilizing an AKS proxy that handles FIC exchanges on behalf of pods. (#43287)
1.25.1 (2025-10-06)
Other Changes
When AZURE_TOKEN_CREDENTIALS is set to ManagedIdentityCredential, DefaultAzureCredential now skips the IMDS endpoint probe request and directly attempts token acquisition with full retry logic, matching the behavior of using ManagedIdentityCredential standalone. (#43080)
Improved error messages from ManagedIdentityCredential to include the full error response from managed identity endpoints for better troubleshooting. (#43231)
1.25.0 (2025-09-11)
Features Added
AzureDeveloperCliCredential now supports claims in get_token and get_token_info. (#42568)
Added new keyword argument require_envvar to DefaultAzureCredential to enforce the presence of the AZURE_TOKEN_CREDENTIALS environment variable. (#42660)
Bugs Fixed
Fixed an issue where AzureDeveloperCliCredential would time out during token requests when azd prompts for user interaction. This issue commonly occurred in environments where the AZD_DEBUG environment variable was set, causing the Azure Developer CLI to display additional prompts that interfered with automated token acquisition. (#42535)
Fixed an issue where credentials configured with a default tenant ID of "organizations" (such as InteractiveBrowserCredential and DeviceCodeCredential) would fail authentication when a specific tenant ID was provided in get_token or get_token_info method calls. (#42721)
Other Changes
Updated SharedTokenCacheCredential to raise CredentialUnavailableError instead of ClientAuthenticationError during token refresh failures when within the context of DefaultAzureCredential. (#42934)
1.24.0 (2025-08-07)
Bugs Fixed
Fixed an issue where CAE (Continuous Access Evaluation) caches were not properly used by AuthorizationCodeCredential and the asynchronous OnBehalfOfCredential. (#42145)
Fixed an issue where brokered authentication was not included in the DefaultAzureCredential chain when AZURE_TOKEN_CREDENTIALS was set to dev. (#42599)
Other Changes
ManagedIdentityCredential now retries IMDS 410 status responses for at least 70 seconds total duration as required by Azure IMDS documentation. (#42330)
Improved DefaultAzureCredential diagnostics when WorkloadIdentityCredential initialization fails. If DAC fails to find a successful credential in the chain, the reason WorkloadIdentityCredential failed will be included in the error message. (#42346)
AzureCliCredential and AzurePowerShellCredential now raise ClientAuthenticationError when claims are provided to get_token or get_token_info, as these credentials do not support claims challenges. The error message includes instructions for handling claims authentication scenarios. (#42568)
1.24.0b1 (2025-07-17)
Features Added
Expanded the set of acceptable values for environment variable AZURE_TOKEN_CREDENTIALS to allow for selection of a specific credential in the DefaultAzureCredential chain. At runtime, only the specified credential will be used when acquiring tokens with DefaultAzureCredential. For example, setting AZURE_TOKEN_CREDENTIALS=WorkloadIdentityCredential will make DefaultAzureCredential use only WorkloadIdentityCredential.
Valid values are EnvironmentCredential, WorkloadIdentityCredential, ManagedIdentityCredential, VisualStudioCodeCredential, AzureCliCredential, AzurePowershellCredential, AzureDeveloperCliCredential, and InteractiveBrowserCredential. (#41709)
Re-enabled VisualStudioCodeCredential - Previously deprecated VisualStudioCodeCredential has been re-implemented to work with the VS Code Azure Resources extension instead of the deprecated Azure Account extension. This requires the azure-identity-broker package to be installed for authentication. (#41822)
VisualStudioCodeCredential is now included in the DefaultAzureCredential token chain by default.
DefaultAzureCredential now supports authentication with the currently signed-in Windows account, provided the azure-identity-broker package is installed. This auth mechanism is added at the end of the DefaultAzureCredential credential chain. (#40335)
1.23.1 (2025-07-15)
Bugs Fixed
Fixed an issue with AzurePowerShellCredential not working correctly for users still using older versions of PowerShell (e.g., Windows PowerShell 5.1) where -AsPlainText is not supported in the ConvertFrom-SecureString cmdlet. (#41675)
Fixed an issue with AzureCliCredential being unable to find the correct az executable for certain Python versions on Windows. (#41806)
1.23.0 (2025-05-13)
Features Added
Added AZURE_TOKEN_CREDENTIALS environment variable to DefaultAzureCredential to allow for choosing groups of credentials.
prod for EnvironmentCredential, WorkloadIdentityCredential, and ManagedIdentityCredential.
dev for SharedTokenCacheCredential, AzureCliCredential, AzurePowershellCredential, and AzureDeveloperCliCredential.
1.22.0 (2025-05-06)
Breaking Changes
Previously, if a client_id or identity_config was specified in ManagedIdentityCredential for Service Fabric managed identity, which is not supported, the client_id (or resource_id/object_id specified identity_config) would be silently ignored. Now, an exception will be raised during a token request if a client_id or identity_config is specified for Service Fabric managed identity.
Bugs Fixed
Fixed an issue with error handling in MSAL-based credentials when the response content is a string rather than a dictionary. (#40281)
Other Changes
Deprecated VisualStudioCodeCredential as the VS Code Azure Account extension on which this credential depends on has been deprecated. See the Azure Account extension deprecation notice. (#40613)
Python 3.8 is no longer supported. Please use Python version 3.9 or later.
1.21.0 (2025-03-11)
Other Changes
Updated the asynchronous CertificateCredential to use the PS256 algorithm with PSS padding for certificate authentication in non-ADFS tenants. (#39761)
Deprecated UsernamePasswordCredential, as it doesn't support multifactor authentication (MFA). MFA will soon be enforced on all Microsoft Entra tenants. For more details, see Planning for mandatory MFA. (#39785)
1.20.0 (2025-02-11)
Features Added
Added subscription parameter to AzureCliCredential to specify the subscription to use when authenticating with the Azure CLI. (#37994)
Bugs Fixed
A bug in the error handling for AzureCliCredentials and AzureDeveloperCliCredential which would result in the unexpected error 'NoneType' object has no attribute 'startswith' has been fixed (#39176)
Other Changes
AzureCliCredential and AzureDeveloperCliCredential will now call their corresponding executables directly instead of going through the shell. (#38606)
ManagedIdentityCredential will now log the configured user-assigned identity if one is set. (#39621)
1.19.0 (2024-10-08)
Bugs Fixed
Fixed the request sent in AzurePipelinesCredential so it doesn't result in a redirect response when an invalid system access token is provided. (#37510)
Other Changes
Deprecated AzureAuthorityHosts.AZURE_GERMANY
1.18.0 (2024-09-19)
Features Added
All credentials now implement the SupportsTokenInfo or AsyncSupportsTokenInfo protocol. Each credential 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. (#36882)
Information on when a token should be refreshed is now saved in AccessTokenInfo (if available).
Other Changes
Added identity config validation to ManagedIdentityCredential to avoid non-deterministic states (e.g. both resource_id and object_id are specified). (#36950)
Additional validation was added for ManagedIdentityCredential in Azure Cloud Shell environments. (#36438)
Bumped minimum dependency on azure-core to >=1.31.0.
1.18.0b2 (2024-08-09)
Features Added
Added support of send_certificate_chain keyword argument when using certs with the synchronous OnBehalfOfCredential. (#36810)
AzurePowerShellCredential now supports using secure strings when authenticating with PowerShell. (#36653)
1.18.0b1 (2024-07-16)
Fixed the issue that SharedTokenCacheCredential was not picklable.
Other Changes
The synchronous ManagedIdentityCredential was updated to use MSAL (Microsoft Authentication Library) for handling most of the underlying managed identity implementations.
1.17.1 (2024-06-21)
Bugs Fixed
Continue to attempt requesting token if the probing request receives non-json response. (#36184)
1.17.0 (2024-06-18)
Breaking Changes
These changes do not impact the API of stable versions such as 1.16.0.
Only code written against a beta version such as 1.17.0b1 is affected.
AzurePipelinesCredential now has a required keyword argument system_access_token. (#35858)
Bugs Fixed
Allow credential chains to continue when an IMDS probe request returns a non-JSON response in ManagedIdentityCredential. (#36016)
1.17.0b2 (2024-06-11)
Features Added
OnBehalfOfCredential now supports client assertion callbacks through the client_assertion_func keyword argument. This enables authenticating with client assertions such as federated credentials. (#35812)
Bugs Fixed
Managed identity bug fixes
1.16.1 (2024-06-11)
Bugs Fixed
Managed identity bug fixes
1.17.0b1 (2024-05-13)
Features Added
Added environment variable AZURE_CLIENT_SEND_CERTIFICATE_CHAIN support for EnvironmentCredential.
Introduced a new credential, AzurePipelinesCredential, for supporting workload identity federation in Azure Pipelines with service connections (#35397).
Bugs Fixed
Fixed typing errors when certain credentials are used as context managers. (#35415)
1.16.0 (2024-04-09)
Other Changes
For IMDS requests in ManagedIdentityCredential, the retry backoff factor was reduced from 2 to 0.8 in order to avoid excessive retry delays and improve responsiveness. Users can customize this setting with the retry_backoff_factor parameter: ManagedIdentityCredential(retry_backoff_factor=2). (#35070)
Fixed an issue in AzurePowerShellCredential where if pwsh isn't available and the Command Prompt language is not English, it would not fall back to powershell. (#34271)
1.16.0b1 (2024-02-06)
Bugs Fixed
Fixed the bug that ClientAssertionCredential constructor fails if kwargs are provided. (#33673)
ManagedIdentityCredential is more lenient with the error message it matches when falling through to the next credential in the chain in the case that Docker Desktop returns a 403 response when attempting to access the IMDS endpoint. (#33928)
Other Changes
AzureCliCredential utilizes the new expires_on property returned by az CLI versions >= 2.54.0 to determine token expiration. (#33947)
Azure-identity is supported on Python 3.8 or later.
Fixed issue InteractiveBrowserCredential does not hand over to next credential in chain if no browser is supported.(#32276)
1.15.0b2 (2023-10-12)
Features Added
Added enable_support_logging as a keyword argument to credentials using MSAL's PublicClientApplication. This allows additional support logging which may contain PII. (#32135)
Breaking Changes
These changes do not impact the API of stable versions such as 1.14.0.
Only code written against a beta version such as 1.15.0b1 may be affected.
Windows Web Account Manager (WAM) Brokered Authentication is moved into another package.
Bugs Fixed
ManagedIdentityCredential will now correctly retry when the instance metadata endpoint returns a 410 response. (#32200)
1.14.1 (2023-10-09)
Bugs Fixed
Bug fixes for developer credentials
1.15.0b1 (2023-09-12)
Features Added
Added Windows Web Account Manager (WAM) Brokered Authentication support.
Added enable_msa_passthrough suppport for InteractiveBrowserCredential. By default InteractiveBrowserCredential only lists Microsoft Entra accounts. If you set enable_msa_passthrough to True, it lists both Microsoft Entra accounts and MSA outlook.com accounts that are logged in to Windows.
Bugs Fixed
Ensure AzurePowershellCredential calls PowerShell with the -NoProfile flag to avoid loading user profiles for more consistent behavior. (#31682)
Fixed an issue with subprocess-based developer credentials (such as AzureCliCredential) where the process would sometimes hang waiting for user input. (#31534)
Fixed an issue with ClientAssertionCredential not properly checking if CAE should be enabled. (#31544)
ManagedIdentityCredential will fall through to the next credential in the chain in the case that Docker Desktop returns a 403 response when attempting to access the IMDS endpoint. (#31824)
Other Changes
Update typing of async credentials to match the AsyncTokenCredential protocol.
If within DefaultAzureCredential, EnvironmentCredential will now use log level INFO instead of WARNING to inform users of an incomplete environment configuration. (#31814)
Strengthened AzureCliCredential and AzureDeveloperCliCredential error checking when determining if a user is logged in or not. Now, if an AADSTS error exists in the error, the full error message is propagated instead of a canned error message. (#30047)
ManagedIdentityCredential instances using IMDS will now be allowed to continue sending requests to the IMDS endpoint even after previous attempts failed. This is to prevent credential instances from potentially being permanently disabled after a temporary network failure.
IMDS endpoint probes in ManagedIdentityCredential will now only occur when inside a credential chain such as DefaultAzureCredential. This probe request timeout has been increased to 1 second from 0.3 seconds to reduce the likelihood of false negatives.
1.14.0 (2023-08-08)
Features Added
Continuous Access Evaluation (CAE) is now configurable per-request by setting the enable_cae keyword argument to True in get_token. This applies to user credentials and service principal credentials. (#30777)
Breaking Changes
CP1 client capabilities for CAE is no longer always-on by default for user credentials. This capability will now be configured as-needed in each get_token request by each SDK. (#30777)
Suffixes are now appended to persistent cache names to indicate whether CAE or non-CAE tokens are stored in the cache. This is to prevent CAE and non-CAE tokens from being mixed/overwritten in the same cache. This could potentially cause issues if you are trying to share the same cache between applications that are using different versions of the Azure Identity library as each application would be reading from a different cache file.
Since CAE is no longer always enabled for user-credentials, the AZURE_IDENTITY_DISABLE_CP1 environment variable is no longer supported.
These changes do not impact the API of stable versions such as 1.12.0.
Only code written against a beta version such as 1.13.0b4 may be affected.
Windows Web Account Manager (WAM) Brokered Authentication is still in preview and not available in this release. It will be available in the next beta release.
Additional Continuous Access Evaluation (CAE) support for service principal credentials is still in preview and not available in this release. It will be available in the next beta release.
Renamed keyword argument developer_credential_timeout to process_timeout in DefaultAzureCredential to remain consistent with the other credentials that launch a subprocess to acquire tokens.
1.13.0b4 (2023-04-11)
Features Added
Credentials that are implemented via launching a subprocess to acquire tokens now have configurable timeouts using the process_timeout keyword argument. This addresses scenarios where these proceses can take longer than the current default timeout values. The affected credentials are AzureCliCredential, AzureDeveloperCliCredential, and AzurePowerShellCredential. (Note: For DefaultAzureCredential, the developer_credential_timeout keyword argument allows users to propagate this option to AzureCliCredential, AzureDeveloperCliCredential, and AzurePowerShellCredential in the authentication chain.) (#28290)
1.13.0b3 (2023-03-07)
Features Added
Changed parameter from instance_discovery to disable_instance_discovery to make it more explicit.
Service principal credentials now enable support for Continuous Access Evaluation (CAE). This indicates to Microsoft Entra ID that your application can handle CAE claims challenges.
1.13.0b2 (2023-02-07)
Features Added
Added AzureDeveloperCredential for Azure Developer CLI. (#27916)
Added WorkloadIdentityCredential for Workload Identity Federation on Kubernetes (#28536)
Added support to use "TryAutoDetect" as the value for AZURE_REGIONAL_AUTHORITY_NAME to enable auto detecting the appropriate authority (#526)
1.13.0b1 (2023-01-10)
Features Added
Added Windows Web Account Manager (WAM) Brokered Authentication support. (#23687)
Breaking Changes
These changes do not impact the API of stable versions such as 1.12.0.
Only code written against a beta version such as 1.12.0b1 may be affected.
Replaced validate_authority with instance_discovery. Now instead of setting validate_authority=False to disable authority validation and instance discovery, you need to use instance_discovery=False.
Bugs Fixed
Fixed an issue where AzureCliCredential would return the wrong error message when the Azure CLI was not installed on non-English consoles. (#27965)
1.12.0 (2022-11-08)
Bugs Fixed
AzureCliCredential now works even when az prints warnings to stderr. (#26857) (thanks to @micromaomao for the contribution)
Fixed issue where user-supplied TokenCachePersistenceOptions weren't propagated when using SharedTokenCacheCredential (#26982)
Breaking Changes
Excluded VisualStudioCodeCredential from DefaultAzureCredential token chain by default as SDK
authentication via Visual Studio Code is broken due to
issue #23249. The VisualStudioCodeCredential will be
re-enabled in the DefaultAzureCredential flow once a fix is in place.
Issue #25713 tracks this. In the meantime
Visual Studio Code users can authenticate their development environment using the Azure CLI.
Other Changes
Added Python 3.11 support and stopped supporting Python 3.6.
1.12.0b2 (2022-10-11)
1.12.0 release candidate
1.12.0b1 (2022-09-22)
Features Added
Added ability to specify tenant_id for AzureCliCredential & AzurePowerShellCredential (thanks @tikicoder) (#25207)
Removed VisualStudioCodeCredential from DefaultAzureCredential token chain. (#23249)
EnvironmentCredential added AZURE_CLIENT_CERTIFICATE_PASSWORD support for the cert password (#24652)
Added validate_authority support for msal client (#22625)
1.11.0 (2022-09-19)
Features Added
Added additionally_allowed_tenants to the following credential options to force explicit opt-in behavior for multi-tenant authentication:
AuthorizationCodeCredential
AzureCliCredential
AzurePowerShellCredential
CertificateCredential
ClientAssertionCredential
ClientSecretCredential
DefaultAzureCredential
OnBehalfOfCredential
UsernamePasswordCredential
VisualStudioCodeCredential
Breaking Changes
Credential types supporting multi-tenant authentication will now throw ClientAuthenticationError if the requested tenant ID doesn't match the credential's tenant ID, and is not included in additionally_allowed_tenants. Applications must now explicitly add additional tenants to the additionally_allowed_tenants list, or add '*' to list, to enable acquiring tokens from tenants other than the originally specified tenant ID.
More information on this change and the consideration behind it can be found here.
These beta features in 1.11.0b3 have been removed from this release and will be added back in 1.12.0b1
tenant_id for AzureCliCredential
removed VisualStudioCodeCredential from DefaultAzureCredential token chain
AZURE_CLIENT_CERTIFICATE_PASSWORD support for EnvironmentCredential
"tenant_id" argument in get_token() method is only supported by:
AuthorizationCodeCredential
AzureCliCredential
AzurePowerShellCredential
InteractiveBrowserCredential
DeviceCodeCredential
EnvironmentCredential
UsernamePasswordCredential
it is ignored by other types of credentials.
Other Changes
Python 2.7 is no longer supported. Please use Python version 3.6 or later.
1.7.1 (2021-11-09)
Bugs Fixed
Fix multi-tenant auth using async AadClient (#21289)
1.7.0 (2021-10-14)
Breaking Changes
These changes do not impact the API of stable versions such as 1.6.0.
Only code written against a beta version such as 1.7.0b1 may be affected.
The allow_multitenant_authentication argument has been removed and the default behavior is now as if it were true.
The multitenant authentication feature can be totally disabled by setting the environment variable
AZURE_IDENTITY_DISABLE_MULTITENANTAUTH to True.
azure.identity.RegionalAuthority is removed.
regional_authority argument is removed for CertificateCredential and ClientSecretCredential.
AzureApplicationCredential is removed.
client_credential in the ctor of OnBehalfOfCredential is removed. Please use client_secret or client_certificate instead.
Make user_assertion in the ctor of OnBehalfOfCredential a keyword only argument.
1.7.0b4 (2021-09-09)
Features Added
CertificateCredential accepts certificates in PKCS12 format
(#13540)
OnBehalfOfCredential supports the on-behalf-of authentication flow for
accessing resources on behalf of users
(#19308)
DefaultAzureCredential allows specifying the client ID of interactive browser via keyword argument interactive_browser_client_id
(#20487)
Other Changes
Added context manager methods and close() to credentials in the
azure.identity namespace. At the end of a with block, or when close()
is called, these credentials close their underlying transport sessions.
(#18798)
1.6.1 (2021-08-19)
Other Changes
Persistent cache implementations are now loaded on demand, enabling
workarounds when importing transitive dependencies such as pywin32
fails
(#19989)
1.7.0b3 (2021-08-10)
Breaking Changes
These changes do not impact the API of stable versions such as 1.6.0.
Only code written against a beta version such as 1.7.0b1 may be affected.
Renamed AZURE_POD_IDENTITY_TOKEN_URL to AZURE_POD_IDENTITY_AUTHORITY_HOST.
The value should now be a host, for example "http://169.254.169.254" (the
default).
Bugs Fixed
Fixed import of azure.identity.aio.AzureApplicationCredential
(#19943)
Other Changes
Added CustomHookPolicy to credential HTTP pipelines. This allows applications
to initialize credentials with raw_request_hook and raw_response_hook
keyword arguments. The value of these arguments should be a callback taking a
PipelineRequest and PipelineResponse, respectively. For example:
ManagedIdentityCredential(raw_request_hook=lambda request: print(request.http_request.url))
Reduced redundant ChainedTokenCredential and DefaultAzureCredential
logging. On Python 3.7+, credentials invoked by these classes now log debug
rather than info messages.
(#18972)
Persistent cache implementations are now loaded on demand, enabling
workarounds when importing transitive dependencies such as pywin32
fails
(#19989)
1.7.0b2 (2021-07-08)
Features Added
InteractiveBrowserCredential keyword argument login_hint enables
pre-filling the username/email address field on the login page
(#19225)
AzureApplicationCredential, a default credential chain for applications
deployed to Azure
(#19309)
Bugs Fixed
azure.identity.aio.ManagedIdentityCredential is an async context manager
that closes its underlying transport session at the end of a with block
Other Changes
Most credentials can use tenant ID values returned from authentication
challenges, enabling them to request tokens from the correct tenant. This
behavior is optional and controlled by a new keyword argument,
allow_multitenant_authentication.
(#19300)
When allow_multitenant_authentication is False, which is the default, a
credential will raise ClientAuthenticationError when its configured tenant
doesn't match the tenant specified for a token request. This may be a
different exception than was raised by prior versions of the credential. To
maintain the prior behavior, set environment variable
AZURE_IDENTITY_ENABLE_LEGACY_TENANT_SELECTION to "True".
CertificateCredential and ClientSecretCredential support regional STS
on Azure VMs by either keyword argument regional_authority or environment
variable AZURE_REGIONAL_AUTHORITY_NAME. See azure.identity.RegionalAuthority
for possible values.
(#19301)
Upgraded minimum azure-core version to 1.11.0 and minimum msal version to
1.12.0
After IMDS authentication fails, ManagedIdentityCredential raises consistent
error messages and uses raise from to propagate inner exceptions
(#19423)
1.7.0b1 (2021-06-08)
Beginning with this release, this library requires Python 2.7 or 3.6+.
Added
VisualStudioCodeCredential gets its default tenant and authority
configuration from VS Code user settings
(#14808)
1.6.0 (2021-05-13)
This is the last version to support Python 3.5. The next version will require
Python 2.7 or 3.6+.
Added
AzurePowerShellCredential authenticates as the identity logged in to Azure
PowerShell. This credential is part of DefaultAzureCredential by default
but can be disabled by a keyword argument:
DefaultAzureCredential(exclude_powershell_credential=True)
(#17341)
Fixed
AzureCliCredential raises CredentialUnavailableError when the CLI times out,
and kills timed out subprocesses
Reduced retry delay for ManagedIdentityCredential on Azure VMs
1.6.0b3 (2021-04-06)
Breaking Changes
These changes do not impact the API of stable versions such as 1.5.0.
Only code written against a beta version such as 1.6.0b1 may be affected.
Credentials consistently retry token requests after connection failures, or
when instructed to by a Retry-After header
ManagedIdentityCredential caches tokens correctly
Added
InteractiveBrowserCredential functions in more WSL environments
(#17615)
1.6.0b2 (2021-03-09)
Breaking Changes
These changes do not impact the API of stable versions such as 1.5.0.
Only code written against a beta version such as 1.6.0b1 may be affected.
Renamed CertificateCredential keyword argument certificate_bytes to
certificate_data
Credentials accepting keyword arguments allow_unencrypted_cache and
enable_persistent_cache to configure persistent caching accept a
cache_persistence_options argument instead whose value should be an
instance of TokenCachePersistenceOptions. For example:
# before (e.g. in 1.6.0b1):
DeviceCodeCredential(enable_persistent_cache=True, allow_unencrypted_cache=True)
# after:
cache_options = TokenCachePersistenceOptions(allow_unencrypted_storage=True)
DeviceCodeCredential(cache_persistence_options=cache_options)
See the documentation and samples for more details.
Added
New class TokenCachePersistenceOptions configures persistent caching
The AuthenticationRequiredError.claims property provides any additional
claims required by a user credential's authenticate() method
1.6.0b1 (2021-02-09)
Changed
Raised minimum msal version to 1.7.0
Raised minimum six version to 1.12.0
Added
InteractiveBrowserCredential uses PKCE internally to protect authorization
codes
CertificateCredential can load a certificate from bytes instead of a file
path. To provide a certificate as bytes, use the keyword argument
certificate_bytes instead of certificate_path, for example:
CertificateCredential(tenant_id, client_id, certificate_bytes=cert_bytes)
(#14055)
User credentials support Continuous Access Evaluation (CAE)
Application authentication APIs from 1.5.0b2
Fixed
ManagedIdentityCredential correctly parses responses from the current
(preview) version of Azure ML managed identity
(#15361)
1.5.0 (2020-11-11)
Breaking Changes
Renamed optional CertificateCredential keyword argument send_certificate
(added in 1.5.0b1) to send_certificate_chain
Removed user authentication APIs added in prior betas. These will be
reintroduced in 1.6.0b1. Passing the keyword arguments below
generally won't cause a runtime error, but the arguments have no effect.
(#14601)
Removed authenticate method from DeviceCodeCredential,
InteractiveBrowserCredential, and UsernamePasswordCredential
Removed allow_unencrypted_cache and enable_persistent_cache keyword
arguments from CertificateCredential, ClientSecretCredential,
DeviceCodeCredential, InteractiveBrowserCredential, and
UsernamePasswordCredential
Removed disable_automatic_authentication keyword argument from
DeviceCodeCredential and InteractiveBrowserCredential
Removed allow_unencrypted_cache keyword argument from
SharedTokenCacheCredential
Removed classes AuthenticationRecord and AuthenticationRequiredError
Removed identity_config keyword argument from ManagedIdentityCredential
(was added in 1.5.0b1)
Changed
DeviceCodeCredential parameter client_id is now optional. When not
provided, the credential will authenticate users to an Azure development
application.
(#14354)
Credentials raise ValueError when constructed with tenant IDs containing
invalid characters
(#14821)
Raised minimum msal version to 1.6.0
Added
ManagedIdentityCredential supports Service Fabric
(#12705)
and Azure Arc
(#12702)
Fixed
Prevent VisualStudioCodeCredential using invalid authentication data when
no user is signed in to Visual Studio Code
(#14438)
ManagedIdentityCredential uses the API version supported by Azure Functions
on Linux consumption hosting plans
(#14670)
InteractiveBrowserCredential.get_token() raises a clearer error message when
it times out waiting for a user to authenticate on Python 2.7
(#14773)
1.5.0b2 (2020-10-07)
Fixed
AzureCliCredential.get_token correctly sets token expiration time,
preventing clients from using expired tokens
(#14345)
AzureCliCredential.get_token correctly sets token expiration time,
preventing clients from using expired tokens
(#14345)
1.5.0b1 (2020-09-08)
Added
Application authentication APIs from 1.4.0b7
ManagedIdentityCredential supports the latest version of App Service
(#11346)
DefaultAzureCredential allows specifying the client ID of a user-assigned
managed identity via keyword argument managed_identity_client_id
(#12991)
CertificateCredential supports Subject Name/Issuer authentication when
created with send_certificate=True. The async CertificateCredential
(azure.identity.aio.CertificateCredential) will support this in a
future version.
(#10816)
Credentials in azure.identity support ADFS authorities, excepting
VisualStudioCodeCredential. To configure a credential for this, configure
the credential with authority and tenant_id="adfs" keyword arguments, for
example
ClientSecretCredential(authority="<your ADFS URI>", tenant_id="adfs").
Async credentials (those in azure.identity.aio) will support ADFS in a
future release.
(#12696)
InteractiveBrowserCredential keyword argument redirect_uri enables
authentication with a user-specified application having a custom redirect URI
(#13344)
Breaking changes
Removed authentication_record keyword argument from the async
SharedTokenCacheCredential, i.e. azure.identity.aio.SharedTokenCacheCredential
1.4.0 (2020-08-10)
Added
DefaultAzureCredential uses the value of environment variable
AZURE_CLIENT_ID to configure a user-assigned managed identity.
(#10931)
Breaking Changes
Renamed VSCodeCredential to VisualStudioCodeCredential
Removed application authentication APIs added in 1.4.0 beta versions. These
will be reintroduced in 1.5.0b1. Passing the keyword arguments below
generally won't cause a runtime error, but the arguments have no effect.
Removed authenticate method from DeviceCodeCredential,
InteractiveBrowserCredential, and UsernamePasswordCredential
Removed allow_unencrypted_cache and enable_persistent_cache keyword
arguments from CertificateCredential, ClientSecretCredential,
DeviceCodeCredential, InteractiveBrowserCredential, and
UsernamePasswordCredential
Removed disable_automatic_authentication keyword argument from
DeviceCodeCredential and InteractiveBrowserCredential
Removed allow_unencrypted_cache keyword argument from
SharedTokenCacheCredential
Removed classes AuthenticationRecord and AuthenticationRequiredError
Removed identity_config keyword argument from ManagedIdentityCredential
1.4.0b7 (2020-07-22)
DefaultAzureCredential has a new optional keyword argument,
visual_studio_code_tenant_id, which sets the tenant the credential should
authenticate in when authenticating as the Azure user signed in to Visual
Studio Code.
Renamed AuthenticationRecord.deserialize positional parameter json_string
to data.
1.4.0b6 (2020-07-07)
AzureCliCredential no longer raises an exception due to unexpected output
from the CLI when run by PyCharm (thanks @NVolcz)
(#11362)
Upgraded minimum msal version to 1.3.0
The async AzureCliCredential correctly invokes /bin/sh
(#12048)
1.4.0b5 (2020-06-12)
Prevent an error on importing AzureCliCredential on Windows caused by a bug
in old versions of Python 3.6 (this bug was fixed in Python 3.6.5).
(#12014)
SharedTokenCacheCredential.get_token raises ValueError instead of
ClientAuthenticationError when called with no scopes.
(#11553)
1.4.0b4 (2020-06-09)
ManagedIdentityCredential can configure a user-assigned identity using any
identifier supported by the current hosting environment. To specify an
identity by its client ID, continue using the client_id argument. To
specify an identity by any other ID, use the identity_config argument,
for example: ManagedIdentityCredential(identity_config={"object_id": ".."})
(#10989)
CertificateCredential and ClientSecretCredential can optionally store
access tokens they acquire in a persistent cache. To enable this, construct
the credential with enable_persistent_cache=True. On Linux, the persistent
cache requires libsecret and pygobject. If these are unavailable or
unusable (e.g. in an SSH session), loading the persistent cache will raise an
error. You may optionally configure the credential to fall back to an
unencrypted cache by constructing it with keyword argument
allow_unencrypted_cache=True.
(#11347)
AzureCliCredential raises CredentialUnavailableError when no user is
logged in to the Azure CLI.
(#11819)
AzureCliCredential and VSCodeCredential, which enable authenticating as
the identity signed in to the Azure CLI and Visual Studio Code, respectively,
can be imported from azure.identity and azure.identity.aio.
azure.identity.aio.AuthorizationCodeCredential.get_token() no longer accepts
optional keyword arguments executor or loop. Prior versions of the method
didn't use these correctly, provoking exceptions, and internal changes in this
version have made them obsolete.
InteractiveBrowserCredential raises CredentialUnavailableError when it
can't start an HTTP server on localhost.
(#11665)
When constructing DefaultAzureCredential, you can now configure a tenant ID
for InteractiveBrowserCredential. When none is specified, the credential
authenticates users in their home tenants. To specify a different tenant, use
the keyword argument interactive_browser_tenant_id, or set the environment
variable AZURE_TENANT_ID.
(#11548)
SharedTokenCacheCredential can be initialized with an AuthenticationRecord
provided by a user credential.
(#11448)
The user authentication API added to DeviceCodeCredential and
InteractiveBrowserCredential in 1.4.0b3 is available on
UsernamePasswordCredential as well.
(#11449)
The optional persistent cache for DeviceCodeCredential and
InteractiveBrowserCredential added in 1.4.0b3 is now available on Linux and
macOS as well as Windows.
(#11134)
On Linux, the persistent cache requires libsecret and pygobject. If these
are unavailable, or libsecret is unusable (e.g. in an SSH session), loading
the persistent cache will raise an error. You may optionally configure the
credential to fall back to an unencrypted cache by constructing it with
keyword argument allow_unencrypted_cache=True.
1.4.0b3 (2020-05-04)
EnvironmentCredential correctly initializes UsernamePasswordCredential
with the value of AZURE_TENANT_ID
(#11127)
Values for the constructor keyword argument authority and
AZURE_AUTHORITY_HOST may optionally specify an "https" scheme. For example,
"https://login.microsoftonline.us" and "login.microsoftonline.us" are both valid.
(#10819)
First preview of new API for authenticating users with DeviceCodeCredential
and InteractiveBrowserCredential
(#10612)
new method authenticate interactively authenticates a user, returns a
serializable AuthenticationRecord
new constructor keyword arguments
authentication_record enables initializing a credential with an
AuthenticationRecord from a prior authentication
disable_automatic_authentication=True configures the credential to raise
AuthenticationRequiredError when interactive authentication is necessary
to acquire a token rather than immediately begin that authentication
enable_persistent_cache=True configures these credentials to use a
persistent cache on supported platforms (in this release, Windows only).
By default they cache in memory only.
Now DefaultAzureCredential can authenticate with the identity signed in to
Visual Studio Code's Azure extension.
(#10472)
1.4.0b2 (2020-04-06)
After an instance of DefaultAzureCredential successfully authenticates, it
uses the same authentication method for every subsequent token request. This
makes subsequent requests more efficient, and prevents unexpected changes of
authentication method.
(#10349)
All get_token methods consistently require at least one scope argument,
raising an error when none is passed. Although get_token() may sometimes
have succeeded in prior versions, it couldn't do so consistently because its
behavior was undefined, and dependened on the credential's type and internal
state. (#10243)
SharedTokenCacheCredential raises CredentialUnavailableError when the
cache is available but contains ambiguous or insufficient information. This
causes ChainedTokenCredential to correctly try the next credential in the
chain. (#10631)
The host of the Active Directory endpoint credentials should use can be set
in the environment variable AZURE_AUTHORITY_HOST. See
azure.identity.KnownAuthorities for a list of common values.
(#8094)
1.3.1 (2020-03-30)
ManagedIdentityCredential raises CredentialUnavailableError when no
identity is configured for an IMDS endpoint. This causes
ChainedTokenCredential to correctly try the next credential in the chain.
(#10488)
1.4.0b1 (2020-03-10)
DefaultAzureCredential can now authenticate using the identity logged in to
the Azure CLI, unless explicitly disabled with a keyword argument:
DefaultAzureCredential(exclude_cli_credential=True)
(#10092)
1.3.0 (2020-02-11)
Correctly parse token expiration time on Windows App Service
(#9393)
Credentials raise CredentialUnavailableError when they can't attempt to
authenticate due to missing data or state
(#9372)
Adopted msal 1.0.0 and msal-extensions 0.1.3
(8359)
1.0.0 (2019-10-29)
Breaking changes:
Async credentials now default to aiohttp
for transport but the library does not require it as a dependency because the
async API is optional. To use async credentials, please install
aiohttp or see
azure-core documentation
for information about customizing the transport.
Renamed ClientSecretCredential parameter "secret" to "client_secret"
All credentials with tenant_id and client_id positional parameters now accept them in that order
Changes to InteractiveBrowserCredential parameters
positional parameter client_id is now an optional keyword argument. If no value is provided,
the Azure CLI's client ID will be used.
AuthorizationCodeCredential authenticates with a previously obtained
authorization code. See Microsoft Entra's
authorization code documentation
for more information about this authentication flow.
Multi-cloud support: client credentials accept the authority of an Azure Active
Directory authentication endpoint as an authority keyword argument. Known
authorities are defined in azure.identity.KnownAuthorities. The default
authority is for Azure Public Cloud, login.microsoftonline.com
(KnownAuthorities.AZURE_PUBLIC_CLOUD). An application running in Azure
Government would use KnownAuthorities.AZURE_GOVERNMENT instead:
from azure.identity import DefaultAzureCredential, KnownAuthorities
credential = DefaultAzureCredential(authority=KnownAuthorities.AZURE_GOVERNMENT)
Breaking changes:
Removed client_secret parameter from InteractiveBrowserCredential
Fixes and improvements:
UsernamePasswordCredential correctly handles environment configuration with
no tenant information (#7260)
user realm discovery requests are sent through credential pipelines
(#7260)
1.0.0b3 (2019-09-10)
New features:
SharedTokenCacheCredential authenticates with tokens stored in a local
cache shared by Microsoft applications. This enables Azure SDK clients to
authenticate silently after you've signed in to Visual Studio 2019, for
example. DefaultAzureCredential includes SharedTokenCacheCredential when
the shared cache is available, and environment variable AZURE_USERNAME
is set. See the
README
for more information.
Removed azure.core.Configuration from the public API in preparation for a
revamped configuration API. Static create_config methods have been renamed
_create_config, and will be removed in a future release.
If you later want to revert to a version requiring azure-core 1.0.0b1,
of this or another Azure SDK library, you must explicitly install azure-core
1.0.0b1 as well. For example:
pip install azure-core==1.0.0b1 azure-identity==1.0.0b1
async versions of these credentials will be added in a future release
1.0.0b1 (2019-06-28)
Version 1.0.0b1 is the first preview of our efforts to create a user-friendly
and Pythonic authentication API for Azure SDK client libraries. For more
information about preview releases of other Azure SDK libraries, please visit
https://aka.ms/azure-sdk-preview1-python.
This release supports service principal and managed identity authentication.
See the
documentation
for more details. User authentication will be added in an upcoming preview
release.
This release supports only global Microsoft Entra tenants, i.e. those
using the https://login.microsoftonline.com authentication endpoint.