Package: azure-identity
Azure Identity client library for PythonThe Azure Identity library providesMicrosoft Entra ID(formerly Azure Active Directory) token authentication support across the Azure SDK. It provides a set ofTokenCredentialimplementations, which can be used to construct Azure SDK clients that support Microsoft Entra token authentication.Source code|Package (PyPI)|Package (Conda)|API reference documentation|Microsoft Entra ID documentationGetting startedInstall the packageInstall Azure Identity with pip:pipinstallazure-identityPrerequisitesAnAzure subscriptionPython 3.7 or a recent version of Python 3 (this library doesn't support end-of-life versions)Authenticate during local developmentWhen debugging and executing code locally, it's typical for developers to use their own accounts for authenticating calls to Azure services. The Azure Identity library supports authenticating through developer tools to simplify local development.Authenticate via Visual Studio CodeDevelopers using Visual Studio Code can use theAzure Account extensionto authenticate via the editor. Apps usingDefaultAzureCredentialorVisualStudioCodeCredentialcan then use this account to authenticate calls in their app when running locally.To authenticate in Visual Studio Code, ensure the Azure Account extension is installed. Once installed, open theCommand Paletteand run theAzure: Sign Incommand.It's aknown issuethatVisualStudioCodeCredentialdoesn't work withAzure Account extensionversions newer than0.9.11. A long-term fix to this problem is in progress. In the meantime, considerauthenticating via the Azure CLI.Authenticate via the Azure CLIDefaultAzureCredentialandAzureCliCredentialcan authenticate as the user signed in to theAzure CLI. To sign in to the Azure CLI, runaz login. On a system with a default web browser, the Azure CLI will launch the browser to authenticate a user.When no default browser is available,az loginwill use the device code authentication flow. This flow can also be selected manually by runningaz login --use-device-code.Authenticate via the Azure Developer CLIDevelopers coding outside of an IDE can also use theAzure Developer CLIto authenticate. Applications using theDefaultAzureCredentialor theAzureDeveloperCliCredentialcan then use this account to authenticate calls in their application when running locally.To authenticate with theAzure Developer CLI, users can run the commandazd auth login. For users running on a system with a default web browser, the Azure Developer CLI will launch the browser to authenticate the user.For systems without a default web browser, theazd auth login --use-device-codecommand will use the device code authentication flow.Key conceptsCredentialsA 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 theCredential classessection below for a list of this library's credential classes.DefaultAzureCredentialDefaultAzureCredentialis appropriate for most applications that will run in Azure because it combines common production credentials with development credentials.DefaultAzureCredentialattempts to authenticate via the following mechanisms, in this order, stopping when one succeeds:Note:DefaultAzureCredentialis intended to simplify getting started with the library by handling common
scenarios with reasonable default behaviors. Developers who want more control or whose scenario
isn't served by the default settings should use other credential types.Environment-DefaultAzureCredentialwill read account information specified viaenvironment variablesand use it to authenticate.Workload Identity- If the application is deployed to Azure Kubernetes Service with Managed Identity enabled,DefaultAzureCredentialwill authenticate with it.Managed Identity- If the application is deployed to an Azure host with Managed Identity enabled,DefaultAzureCredentialwill authenticate with it.Azure CLI- If a user has signed in via the Azure CLIaz logincommand,DefaultAzureCredentialwill authenticate as that user.Azure PowerShell- If a user has signed in via Azure PowerShell'sConnect-AzAccountcommand,DefaultAzureCredentialwill authenticate as that user.Azure Developer CLI- If the developer has authenticated via the Azure Developer CLIazd auth logincommand, theDefaultAzureCredentialwill authenticate with that account.Interactive browser- If enabled,DefaultAzureCredentialwill interactively authenticate a user via the default browser. This credential type is disabled by default.Continuation policyAs of version 1.14.0,DefaultAzureCredentialwill attempt 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, soDefaultAzureCredentialwill continue to the next credential in the flow. Deployed service credentials will 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.Note aboutVisualStudioCodeCredentialDue to aknown issue,VisualStudioCodeCredentialhas been removed from theDefaultAzureCredentialtoken chain. When the issue is resolved in a future release, this change will be reverted.ExamplesThe following examples are provided below:Authenticate with DefaultAzureCredentialDefine a custom authentication flow with ChainedTokenCredentialAsync credentialsAuthenticate withDefaultAzureCredentialMore details on configuring your environment to use theDefaultAzureCredentialcan be found in the class'sreference documentation.This example demonstrates authenticating theBlobServiceClientfrom theazure-storage-bloblibrary usingDefaultAzureCredential.fromazure.identityimportDefaultAzureCredentialfromazure.storage.blobimportBlobServiceClientdefault_credential=DefaultAzureCredential()client=BlobServiceClient(account_url,credential=default_credential)Enable interactive authentication withDefaultAzureCredentialInteractive authentication is disabled in theDefaultAzureCredentialby default and can be enabled with a keyword argument:DefaultAzureCredential(exclude_interactive_browser_credential=False)When enabled,DefaultAzureCredentialfalls back to interactively authenticating via the system's default web browser when no other credential is available.Specify a user-assigned managed identity forDefaultAzureCredentialMany Azure hosts allow the assignment of a user-assigned managed identity. To configureDefaultAzureCredentialto authenticate a user-assigned identity, use themanaged_identity_client_idkeyword argument:DefaultAzureCredential(managed_identity_client_id=client_id)Alternatively, set the environment variableAZURE_CLIENT_IDto the identity's client ID.Define a custom authentication flow withChainedTokenCredentialDefaultAzureCredentialis generally the quickest way to get started developing applications for Azure. For more advanced scenarios,ChainedTokenCredentiallinks multiple credential instances to be tried sequentially when authenticating. It will try each chained credential in turn until one provides a token or fails to authenticate due to an error.The following example demonstrates creating a credential that will first attempt to authenticate using managed identity. The credential will fall back to authenticating via the Azure CLI when a managed identity is unavailable. This example uses theEventHubProducerClientfrom theazure-eventhubclient library.fromazure.eventhubimportEventHubProducerClientfromazure.identityimportAzureCliCredential,ChainedTokenCredential,ManagedIdentityCredentialmanaged_identity=ManagedIdentityCredential()azure_cli=AzureCliCredential()credential_chain=ChainedTokenCredential(managed_identity,azure_cli)client=EventHubProducerClient(namespace,eventhub_name,credential_chain)Async credentialsThis library includes a set of async APIs. To use the async credentials inazure.identity.aio, you must first install an async transport, such asaiohttp. For more information, seeazure-core documentation.Async credentials should be closed when they're no longer needed. Each async credential is an async context manager and defines an asyncclosemethod. For example:fromazure.identity.aioimportDefaultAzureCredential# call close when the credential is no longer neededcredential=DefaultAzureCredential()...awaitcredential.close()# alternatively, use the credential as an async context managercredential=DefaultAzureCredential()asyncwithcredential:...This example demonstrates authenticating the asynchronousSecretClientfromazure-keyvault-secretswith an asynchronous
credential.fromazure.identity.aioimportDefaultAzureCredentialfromazure.keyvault.secrets.aioimportSecretClientdefault_credential=DefaultAzureCredential()client=SecretClient("https://my-vault.vault.azure.net",default_credential)Managed identity supportManaged identity authenticationis supported via either theDefaultAzureCredentialor theManagedIdentityCredentialdirectly for the following Azure services:Azure App Service and Azure FunctionsAzure ArcAzure Cloud ShellAzure Kubernetes ServiceAzure Service FabricAzure Virtual MachinesAzure Virtual Machines Scale SetsExamplesAuthenticate with a user-assigned managed identityfromazure.identityimportManagedIdentityCredentialfromazure.keyvault.secretsimportSecretClientcredential=ManagedIdentityCredential(client_id=managed_identity_client_id)client=SecretClient("https://my-vault.vault.azure.net",credential)Authenticate with a system-assigned managed identityfromazure.identityimportManagedIdentityCredentialfromazure.keyvault.secretsimportSecretClientcredential=ManagedIdentityCredential()client=SecretClient("https://my-vault.vault.azure.net",credential)Cloud configurationCredentials 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 theauthorityargument.AzureAuthorityHostsdefines authorities for well-known clouds:fromazure.identityimportAzureAuthorityHostsDefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_GOVERNMENT)If the authority for your cloud isn't listed inAzureAuthorityHosts, you can explicitly specify its URL:DefaultAzureCredential(authority="https://login.partner.microsoftonline.cn")As an alternative to specifying theauthorityargument, you can also set theAZURE_AUTHORITY_HOSTenvironment variable to the URL of your cloud's authority. This approach is useful when configuring multiple credentials to authenticate to the same cloud:AZURE_AUTHORITY_HOST=https://login.partner.microsoftonline.cnNot all credentials require this configuration. Credentials that authenticate through a development tool, such asAzureCliCredential, use that tool's configuration. Similarly,VisualStudioCodeCredentialaccepts anauthorityargument but defaults to the authority matching VS Code's "Azure: Cloud" setting.Credential classesAuthenticate Azure-hosted applicationsCredentialUsageDefaultAzureCredentialProvides a simplified authentication experience to quickly start developing applications run in Azure.ChainedTokenCredentialAllows users to define custom authentication flows composing multiple credentials.EnvironmentCredentialAuthenticates a service principal or user via credential information specified in environment variables.ManagedIdentityCredentialAuthenticates the managed identity of an Azure resource.WorkloadIdentityCredentialSupportsMicrosoft Entra Workload IDon Kubernetes.Authenticate service principalsCredentialUsageReferenceCertificateCredentialAuthenticates a service principal using a certificate.Service principal authenticationClientAssertionCredentialAuthenticates a service principal using a signed client assertion.ClientSecretCredentialAuthenticates a service principal using a secret.Service principal authenticationAuthenticate usersCredentialUsageReferenceAuthorizationCodeCredentialAuthenticates a user with a previously obtained authorization code.OAuth2 authentication codeDeviceCodeCredentialInteractively authenticates a user on devices with limited UI.Device code authenticationInteractiveBrowserCredentialInteractively authenticates a user with the default system browser.OAuth2 authentication codeOnBehalfOfCredentialPropagates the delegated user identity and permissions through the request chain.On-behalf-of authenticationUsernamePasswordCredentialAuthenticates a user with a username and password (doesn't support multi-factor authentication).Username + password authenticationAuthenticate via development toolsCredentialUsageReferenceAzureCliCredentialAuthenticates in a development environment with the Azure CLI.Azure CLI authenticationAzureDeveloperCliCredentialAuthenticates in a development environment with the Azure Developer CLI.Azure Developer CLI ReferenceAzurePowerShellCredentialAuthenticates in a development environment with the Azure PowerShell.Azure PowerShell authenticationVisualStudioCodeCredentialAuthenticates as the user signed in to the Visual Studio Code Azure Account extension.VS Code Azure Account extensionEnvironment variablesDefaultAzureCredentialandEnvironmentCredentialcan be configured with environment variables. Each type of authentication requires values for specific
variables:Service principal with secretVariable nameValueAZURE_CLIENT_IDID of a Microsoft Entra applicationAZURE_TENANT_IDID of the application's Microsoft Entra tenantAZURE_CLIENT_SECRETone of the application's client secretsService principal with certificateVariable nameValueAZURE_CLIENT_IDID of a Microsoft Entra applicationAZURE_TENANT_IDID of the application's Microsoft Entra tenantAZURE_CLIENT_CERTIFICATE_PATHpath to a PEM or PKCS12 certificate file including private keyAZURE_CLIENT_CERTIFICATE_PASSWORDpassword of the certificate file, if anyUsername and passwordVariable nameValueAZURE_CLIENT_IDID of a Microsoft Entra applicationAZURE_USERNAMEa username (usually an email address)AZURE_PASSWORDthat user's passwordConfiguration is attempted in the above order. For example, if values for a client secret and certificate are both present, the client secret will be used.Continuous Access EvaluationAs of version 1.14.0, accessing resources protected byContinuous Access Evaluation (CAE)is possible on a per-request basis. This behavior can be enabled by setting theenable_caekeyword argument toTruein the credential'sget_tokenmethod. CAE isn't supported for developer and managed identity credentials.Token cachingToken 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 details, see thetoken caching documentation.Brokered authenticationAn 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. To enable support, use theazure-identity-brokerpackage. For details on authenticating using WAM, see thebroker plugin documentation.TroubleshootingSee thetroubleshooting guidefor details on how to diagnose various failure scenarios.Error handlingCredentials raiseCredentialUnavailableErrorwhen they're unable to attempt authentication because they lack required data or state. For example,EnvironmentCredentialwill raise this exception whenits configurationis incomplete.Credentials raiseazure.core.exceptions.ClientAuthenticationErrorwhen they fail to authenticate.ClientAuthenticationErrorhas amessageattribute, which describes why authentication failed. When raised byDefaultAzureCredentialorChainedTokenCredential, 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 IDerror code documentation.LoggingThis library uses the standardlogginglibrary 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 thelogging_enableargument. For example:credential=DefaultAzureCredential(logging_enable=True)CAUTION: DEBUG level logs from credentials contain sensitive information.
These logs must be protected to avoid compromising account security.Next stepsClient library supportClient and management libraries listed on theAzure SDK release pagethat 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 issuesThis library doesn't supportAzure AD B2C.For other open issues, refer to the library'sGitHub repository.Provide feedbackIf you encounter bugs or have suggestions,open an issue.ContributingThis 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, visithttps://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.This project has adopted theMicrosoft Open Source Code of Conduct. For more information, see theCode of Conduct FAQor contactopencode@microsoft.comwith any additional questions or comments.Release History1.15.0 (2023-10-26)Features AddedAdded bearer token provider.  (#32655)Bugs FixedFixed issue InteractiveBrowserCredential does not hand over to next credential in chain if no browser is supported.(#32276)1.15.0b2 (2023-10-12)Features AddedAddedenable_support_loggingas a keyword argument to credentials using MSAL'sPublicClientApplication. This allows additional support logging which may contain PII. (#32135)Breaking ChangesThese 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 FixedManagedIdentityCredentialwill now correctly retry when the instance metadata endpoint returns a 410 response.  (#32200)1.14.1 (2023-10-09)Bugs FixedBug fixes for developer credentials1.15.0b1 (2023-09-12)Features AddedAdded Windows Web Account Manager (WAM) Brokered Authentication support.Addedenable_msa_passthroughsuppport forInteractiveBrowserCredential. By defaultInteractiveBrowserCredentialonly lists Microsoft Entra accounts. If you setenable_msa_passthroughtoTrue, it lists both Microsoft Entra accounts and MSA outlook.com accounts that are logged in to Windows.Bugs FixedEnsureAzurePowershellCredentialcalls PowerShell with the-NoProfileflag 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 withClientAssertionCredentialnot properly checking if CAE should be enabled.  (#31544)ManagedIdentityCredentialwill 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 ChangesUpdate typing of async credentials to match theAsyncTokenCredentialprotocol.If withinDefaultAzureCredential,EnvironmentCredentialwill now use log level INFO instead of WARNING to inform users of an incomplete environment configuration.  (#31814)StrengthenedAzureCliCredentialandAzureDeveloperCliCredentialerror checking when determining if a user is logged in or not. Now, if anAADSTSerror exists in the error, the full error message is propagated instead of a canned error message. (#30047)ManagedIdentityCredentialinstances 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 inManagedIdentityCredentialwill now only occur when inside a credential chain such asDefaultAzureCredential. 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 AddedContinuous Access Evaluation (CAE) is now configurable per-request by setting theenable_caekeyword argument toTrueinget_token. This applies to user credentials and service principal credentials.  (#30777)Breaking ChangesCP1 client capabilities for CAE is no longer always-on by default for user credentials. This capability will now be configured as-needed in eachget_tokenrequest 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, theAZURE_IDENTITY_DISABLE_CP1environment variable is no longer supported.Bugs FixedCredential types correctly implementazure-core'sTokenCredentialprotocol.  (#25175)1.14.0b2 (2023-07-11)Features AddedAddedworkload_identity_tenant_idsupport inDefaultAzureCredential.1.14.0b1 (2023-06-06)Features AddedContinue attempt next credential when finding an expired token from cached token credential in DefaultAzureCredential. (#30441)Other ChangesVisualStudioCodeCredential prints an informative error message when used (as it is currently broken) (#30385)Removed dependency onsix. (#30613)1.13.0 (2023-05-11)Breaking ChangesThese 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 argumentdeveloper_credential_timeouttoprocess_timeoutinDefaultAzureCredentialto remain consistent with the other credentials that launch a subprocess to acquire tokens.1.13.0b4 (2023-04-11)Features AddedCredentials that are implemented via launching a subprocess to acquire tokens now have configurable timeouts using theprocess_timeoutkeyword argument. This addresses scenarios where these proceses can take longer than the current default timeout values. The affected credentials areAzureCliCredential,AzureDeveloperCliCredential, andAzurePowerShellCredential. (Note: ForDefaultAzureCredential, thedeveloper_credential_timeoutkeyword argument allows users to propagate this option toAzureCliCredential,AzureDeveloperCliCredential, andAzurePowerShellCredentialin the authentication chain.) (#28290)1.13.0b3 (2023-03-07)Features AddedChanged parameter frominstance_discoverytodisable_instance_discoveryto make it more explicit.Service principal credentials now enable support forContinuous Access Evaluation (CAE). This indicates to Microsoft Entra ID that your application can handle CAE claims challenges.1.13.0b2 (2023-02-07)Features AddedAddedAzureDeveloperCredentialfor Azure Developer CLI. (#27916)AddedWorkloadIdentityCredentialfor Workload Identity Federation on Kubernetes (#28536)Added support to use "TryAutoDetect" as the value forAZURE_REGIONAL_AUTHORITY_NAMEto enable auto detecting the appropriate authority (#526)1.13.0b1 (2023-01-10)Features AddedAdded Windows Web Account Manager (WAM) Brokered Authentication support. (#23687)Breaking ChangesThese 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.Replacedvalidate_authoritywithinstance_discovery. Now instead of setting validate_authority=False to disable authority validation and instance discovery, you need to use instance_discovery=False.Bugs FixedFixed an issue whereAzureCliCredentialwould return the wrong error message when the Azure CLI was not installed on non-English consoles. (#27965)1.12.0 (2022-11-08)Bugs FixedAzureCliCredentialnow works even whenazprints warnings to stderr. (#26857) (thanks to @micromaomao for the contribution)Fixed issue where user-suppliedTokenCachePersistenceOptionsweren't propagated when usingSharedTokenCacheCredential(#26982)Breaking ChangesExcludedVisualStudioCodeCredentialfromDefaultAzureCredentialtoken chain by default as SDK
authentication via Visual Studio Code is broken due to
issue#23249. TheVisualStudioCodeCredentialwill be
re-enabled in theDefaultAzureCredentialflow once a fix is in place.
Issue#25713tracks this. In the meantime
Visual Studio Code users can authenticate their development environment using theAzure CLI.Other ChangesAdded Python 3.11 support and stopped supporting Python 3.6.1.12.0b2 (2022-10-11)1.12.0 release candidate1.12.0b1 (2022-09-22)Features AddedAdded ability to specifytenant_idforAzureCliCredential&AzurePowerShellCredential(thanks @tikicoder)    (#25207)RemovedVisualStudioCodeCredentialfromDefaultAzureCredentialtoken chain. (#23249)EnvironmentCredentialaddedAZURE_CLIENT_CERTIFICATE_PASSWORDsupport for the cert password    (#24652)Addedvalidate_authoritysupport for msal client  (#22625)1.11.0 (2022-09-19)Features AddedAddedadditionally_allowed_tenantsto the following credential options to force explicit opt-in behavior for multi-tenant authentication:AuthorizationCodeCredentialAzureCliCredentialAzurePowerShellCredentialCertificateCredentialClientAssertionCredentialClientSecretCredentialDefaultAzureCredentialOnBehalfOfCredentialUsernamePasswordCredentialVisualStudioCodeCredentialBreaking ChangesCredential types supporting multi-tenant authentication will now throwClientAuthenticationErrorif the requested tenant ID doesn't match the credential's tenant ID, and is not included inadditionally_allowed_tenants. Applications must now explicitly add additional tenants to theadditionally_allowed_tenantslist, 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 foundhere.These beta features in 1.11.0b3 have been removed from this release and will be added back in 1.12.0b1tenant_idforAzureCliCredentialremovedVisualStudioCodeCredentialfromDefaultAzureCredentialtoken chainAZURE_CLIENT_CERTIFICATE_PASSWORDsupport forEnvironmentCredentialvalidate_authoritysupport1.11.0b3 (2022-08-09)Azure-identity is supported on Python 3.7 or later. For more details, please read our page onAzure SDK for Python version support policy.Features AddedAdded ability to specifytenant_idforAzureCliCredential(thanks @tikicoder)    (#25207)Breaking ChangesRemovedVisualStudioCodeCredentialfromDefaultAzureCredentialtoken chain. (#23249)1.11.0b2 (2022-07-05)Features AddedEnvironmentCredentialaddedAZURE_CLIENT_CERTIFICATE_PASSWORDsupport for the cert password    (#24652)Bugs FixedFixed the issue that failed to parse PEM certificate if it does not start with "-----"    (#24643)1.11.0b1 (2022-05-10)Features AddedAddedvalidate_authoritysupport for msal client  (#22625)1.10.0 (2022-04-28)Breaking ChangesThese changes do not impact the API of stable versions such as 1.9.0.
Only code written against a beta version such as 1.10.0b1 may be affected.validate_authoritysupport is not available in 1.10.0.Other ChangesSupported msal-extensions version 1.0.0    (#23927)1.10.0b1 (2022-04-07)Features AddedAddedvalidate_authoritysupport for msal client  (#22625)1.9.0 (2022-04-05)Features AddedAdded PII logging if logging.DEBUG is enabled.    (#23203)Breaking ChangesThese changes do not impact the API of stable versions such as 1.8.0.
Only code written against a beta version such as 1.9.0b1 may be affected.validate_authoritysupport is not available in 1.9.0.Bugs FixedAdded check oncontentfrom msal response.    (#23483)Fixed the issue that async OBO credential does not refresh correctly.    (#21981)Other ChangesRemovedresource_id, please useidentity_configinstead.Renamed argument nameget_assertiontofuncforClientAssertionCredential.1.9.0b1 (2022-03-08)Features AddedAddedvalidate_authoritysupport for msal client  (#22625)Addedresource_idsupport for user-assigned managed identity  (#22329)AddedClientAssertionCredentialsupport  (#22328)Updated App service API version to "2019-08-01" (#23034)1.8.0 (2022-03-01)Bugs FixedHandle injected "tenant_id" and "claims" (#23138)"tenant_id" argument in get_token() method is only supported by:AuthorizationCodeCredentialAzureCliCredentialAzurePowerShellCredentialInteractiveBrowserCredentialDeviceCodeCredentialEnvironmentCredentialUsernamePasswordCredentialit is ignored by other types of credentials.Other ChangesPython 2.7 is no longer supported. Please use Python version 3.6 or later.1.7.1 (2021-11-09)Bugs FixedFix multi-tenant auth using async AadClient (#21289)1.7.0 (2021-10-14)Breaking ChangesThese 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.Theallow_multitenant_authenticationargument 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 variableAZURE_IDENTITY_DISABLE_MULTITENANTAUTHtoTrue.azure.identity.RegionalAuthorityis removed.regional_authorityargument is removed forCertificateCredentialandClientSecretCredential.AzureApplicationCredentialis removed.client_credentialin the ctor ofOnBehalfOfCredentialis removed. Please useclient_secretorclient_certificateinstead.Makeuser_assertionin the ctor ofOnBehalfOfCredentiala keyword only argument.1.7.0b4 (2021-09-09)Features AddedCertificateCredentialaccepts certificates in PKCS12 format
(#13540)OnBehalfOfCredentialsupports the on-behalf-of authentication flow for
accessing resources on behalf of users
(#19308)DefaultAzureCredentialallows specifying the client ID of interactive browser via keyword argumentinteractive_browser_client_id(#20487)Other ChangesAdded context manager methods andclose()to credentials in theazure.identitynamespace. At the end of awithblock, or whenclose()is called, these credentials close their underlying transport sessions.
(#18798)1.6.1 (2021-08-19)Other ChangesPersistent 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 ChangesThese 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.RenamedAZURE_POD_IDENTITY_TOKEN_URLtoAZURE_POD_IDENTITY_AUTHORITY_HOST.
The value should now be a host, for example "http://169.254.169.254" (the
default).Bugs FixedFixed import ofazure.identity.aio.AzureApplicationCredential(#19943)Other ChangesAddedCustomHookPolicyto credential HTTP pipelines. This allows applications
to initialize credentials withraw_request_hookandraw_response_hookkeyword arguments. The value of these arguments should be a callback taking aPipelineRequestandPipelineResponse, respectively. For example:ManagedIdentityCredential(raw_request_hook=lambda request: print(request.http_request.url))Reduced redundantChainedTokenCredentialandDefaultAzureCredentiallogging. 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 AddedInteractiveBrowserCredentialkeyword argumentlogin_hintenables
pre-filling the username/email address field on the login page
(#19225)AzureApplicationCredential, a default credential chain for applications
deployed to Azure
(#19309)Bugs Fixedazure.identity.aio.ManagedIdentityCredentialis an async context manager
that closes its underlying transport session at the end of awithblockOther ChangesMost 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)Whenallow_multitenant_authenticationis False, which is the default, a
credential will raiseClientAuthenticationErrorwhen 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".CertificateCredentialandClientSecretCredentialsupport regional STS
on Azure VMs by either keyword argumentregional_authorityor environment
variableAZURE_REGIONAL_AUTHORITY_NAME. Seeazure.identity.RegionalAuthorityfor possible values.
(#19301)Upgraded minimumazure-coreversion to 1.11.0 and minimummsalversion to
1.12.0After IMDS authentication fails,ManagedIdentityCredentialraises consistent
error messages and usesraise fromto propagate inner exceptions
(#19423)1.7.0b1 (2021-06-08)Beginning with this release, this library requires Python 2.7 or 3.6+.AddedVisualStudioCodeCredentialgets 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+.AddedAzurePowerShellCredentialauthenticates as the identity logged in to Azure
PowerShell. This credential is part ofDefaultAzureCredentialby default
but can be disabled by a keyword argument:DefaultAzureCredential(exclude_powershell_credential=True)(#17341)FixedAzureCliCredentialraisesCredentialUnavailableErrorwhen the CLI times out,
and kills timed out subprocessesReduced retry delay forManagedIdentityCredentialon Azure VMs1.6.0b3 (2021-04-06)Breaking ChangesThese 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.Removed propertyAuthenticationRequiredError.error_detailsFixedCredentials consistently retry token requests after connection failures, or
when instructed to by a Retry-After headerManagedIdentityCredential caches tokens correctlyAddedInteractiveBrowserCredentialfunctions in more WSL environments
(#17615)1.6.0b2 (2021-03-09)Breaking ChangesThese 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.RenamedCertificateCredentialkeyword argumentcertificate_bytestocertificate_dataCredentials accepting keyword argumentsallow_unencrypted_cacheandenable_persistent_cacheto configure persistent caching accept acache_persistence_optionsargument instead whose value should be an
instance ofTokenCachePersistenceOptions. 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.AddedNew classTokenCachePersistenceOptionsconfigures persistent cachingTheAuthenticationRequiredError.claimsproperty provides any additional
claims required by a user credential'sauthenticate()method1.6.0b1 (2021-02-09)ChangedRaised minimum msal version to 1.7.0Raised minimum six version to 1.12.0AddedInteractiveBrowserCredentialuses PKCE internally to protect authorization
codesCertificateCredentialcan load a certificate from bytes instead of a file
path. To provide a certificate as bytes, use the keyword argumentcertificate_bytesinstead ofcertificate_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.0b2FixedManagedIdentityCredentialcorrectly parses responses from the current
(preview) version of Azure ML managed identity
(#15361)1.5.0 (2020-11-11)Breaking ChangesRenamed optionalCertificateCredentialkeyword argumentsend_certificate(added in 1.5.0b1) tosend_certificate_chainRemoved 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)Removedauthenticatemethod fromDeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredentialRemovedallow_unencrypted_cacheandenable_persistent_cachekeyword
arguments fromCertificateCredential,ClientSecretCredential,DeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredentialRemoveddisable_automatic_authenticationkeyword argument fromDeviceCodeCredentialandInteractiveBrowserCredentialRemovedallow_unencrypted_cachekeyword argument fromSharedTokenCacheCredentialRemoved classesAuthenticationRecordandAuthenticationRequiredErrorRemovedidentity_configkeyword argument fromManagedIdentityCredential(was added in 1.5.0b1)ChangedDeviceCodeCredentialparameterclient_idis now optional. When not
provided, the credential will authenticate users to an Azure development
application.
(#14354)Credentials raiseValueErrorwhen constructed with tenant IDs containing
invalid characters
(#14821)Raised minimum msal version to 1.6.0AddedManagedIdentityCredentialsupports Service Fabric
(#12705)
and Azure Arc
(#12702)FixedPreventVisualStudioCodeCredentialusing invalid authentication data when
no user is signed in to Visual Studio Code
(#14438)ManagedIdentityCredentialuses 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)FixedAzureCliCredential.get_tokencorrectly sets token expiration time,
preventing clients from using expired tokens
(#14345)ChangedAdopted msal-extensions 0.3.0
(#13107)1.4.1 (2020-10-07)FixedAzureCliCredential.get_tokencorrectly sets token expiration time,
preventing clients from using expired tokens
(#14345)1.5.0b1 (2020-09-08)AddedApplication authentication APIs from 1.4.0b7ManagedIdentityCredentialsupports the latest version of App Service
(#11346)DefaultAzureCredentialallows specifying the client ID of a user-assigned
managed identity via keyword argumentmanaged_identity_client_id(#12991)CertificateCredentialsupports Subject Name/Issuer authentication when
created withsend_certificate=True. The asyncCertificateCredential(azure.identity.aio.CertificateCredential) will support this in a
future version.
(#10816)Credentials inazure.identitysupport ADFS authorities, exceptingVisualStudioCodeCredential. To configure a credential for this, configure
the credential withauthorityandtenant_id="adfs"keyword arguments, for
exampleClientSecretCredential(authority="<your ADFS URI>", tenant_id="adfs").
Async credentials (those inazure.identity.aio) will support ADFS in a
future release.
(#12696)InteractiveBrowserCredentialkeyword argumentredirect_urienables
authentication with a user-specified application having a custom redirect URI
(#13344)Breaking changesRemovedauthentication_recordkeyword argument from the asyncSharedTokenCacheCredential, i.e.azure.identity.aio.SharedTokenCacheCredential1.4.0 (2020-08-10)AddedDefaultAzureCredentialuses the value of environment variableAZURE_CLIENT_IDto configure a user-assigned managed identity.
(#10931)Breaking ChangesRenamedVSCodeCredentialtoVisualStudioCodeCredentialRemoved 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.Removedauthenticatemethod fromDeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredentialRemovedallow_unencrypted_cacheandenable_persistent_cachekeyword
arguments fromCertificateCredential,ClientSecretCredential,DeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredentialRemoveddisable_automatic_authenticationkeyword argument fromDeviceCodeCredentialandInteractiveBrowserCredentialRemovedallow_unencrypted_cachekeyword argument fromSharedTokenCacheCredentialRemoved classesAuthenticationRecordandAuthenticationRequiredErrorRemovedidentity_configkeyword argument fromManagedIdentityCredential1.4.0b7 (2020-07-22)DefaultAzureCredentialhas 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.RenamedAuthenticationRecord.deserializepositional parameterjson_stringtodata.1.4.0b6 (2020-07-07)AzureCliCredentialno longer raises an exception due to unexpected output
from the CLI when run by PyCharm (thanks @NVolcz)
(#11362)Upgraded minimummsalversion to 1.3.0The asyncAzureCliCredentialcorrectly invokes/bin/sh(#12048)1.4.0b5 (2020-06-12)Prevent an error on importingAzureCliCredentialon Windows caused by a bug
in old versions of Python 3.6 (this bug was fixed in Python 3.6.5).
(#12014)SharedTokenCacheCredential.get_tokenraisesValueErrorinstead ofClientAuthenticationErrorwhen called with no scopes.
(#11553)1.4.0b4 (2020-06-09)ManagedIdentityCredentialcan configure a user-assigned identity using any
identifier supported by the current hosting environment. To specify an
identity by its client ID, continue using theclient_idargument. To
specify an identity by any other ID, use theidentity_configargument,
for example:ManagedIdentityCredential(identity_config={"object_id": ".."})(#10989)CertificateCredentialandClientSecretCredentialcan optionally store
access tokens they acquire in a persistent cache. To enable this, construct
the credential withenable_persistent_cache=True. On Linux, the persistent
cache requires libsecret andpygobject. 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 argumentallow_unencrypted_cache=True.
(#11347)AzureCliCredentialraisesCredentialUnavailableErrorwhen no user is
logged in to the Azure CLI.
(#11819)AzureCliCredentialandVSCodeCredential, which enable authenticating as
the identity signed in to the Azure CLI and Visual Studio Code, respectively,
can be imported fromazure.identityandazure.identity.aio.azure.identity.aio.AuthorizationCodeCredential.get_token()no longer accepts
optional keyword argumentsexecutororloop. Prior versions of the method
didn't use these correctly, provoking exceptions, and internal changes in this
version have made them obsolete.InteractiveBrowserCredentialraisesCredentialUnavailableErrorwhen it
can't start an HTTP server onlocalhost.
(#11665)When constructingDefaultAzureCredential, you can now configure a tenant ID
forInteractiveBrowserCredential. When none is specified, the credential
authenticates users in their home tenants. To specify a different tenant, use
the keyword argumentinteractive_browser_tenant_id, or set the environment
variableAZURE_TENANT_ID.
(#11548)SharedTokenCacheCredentialcan be initialized with anAuthenticationRecordprovided by a user credential.
(#11448)The user authentication API added toDeviceCodeCredentialandInteractiveBrowserCredentialin 1.4.0b3 is available onUsernamePasswordCredentialas well.
(#11449)The optional persistent cache forDeviceCodeCredentialandInteractiveBrowserCredentialadded in 1.4.0b3 is now available on Linux and
macOS as well as Windows.
(#11134)On Linux, the persistent cache requires libsecret andpygobject. 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 argumentallow_unencrypted_cache=True.1.4.0b3 (2020-05-04)EnvironmentCredentialcorrectly initializesUsernamePasswordCredentialwith the value ofAZURE_TENANT_ID(#11127)Values for the constructor keyword argumentauthorityandAZURE_AUTHORITY_HOSTmay 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 withDeviceCodeCredentialandInteractiveBrowserCredential(#10612)new methodauthenticateinteractively authenticates a user, returns a
serializableAuthenticationRecordnew constructor keyword argumentsauthentication_recordenables initializing a credential with anAuthenticationRecordfrom a prior authenticationdisable_automatic_authentication=Trueconfigures the credential to raiseAuthenticationRequiredErrorwhen interactive authentication is necessary
to acquire a token rather than immediately begin that authenticationenable_persistent_cache=Trueconfigures these credentials to use a
persistent cache on supported platforms (in this release, Windows only).
By default they cache in memory only.NowDefaultAzureCredentialcan authenticate with the identity signed in to
Visual Studio Code's Azure extension.
(#10472)1.4.0b2 (2020-04-06)After an instance ofDefaultAzureCredentialsuccessfully 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)Allget_tokenmethods consistently require at least one scope argument,
raising an error when none is passed. Althoughget_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)SharedTokenCacheCredentialraisesCredentialUnavailableErrorwhen the
cache is available but contains ambiguous or insufficient information. This
causesChainedTokenCredentialto 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 variableAZURE_AUTHORITY_HOST. Seeazure.identity.KnownAuthoritiesfor a list of common values.
(#8094)1.3.1 (2020-03-30)ManagedIdentityCredentialraisesCredentialUnavailableErrorwhen no
identity is configured for an IMDS endpoint. This causesChainedTokenCredentialto correctly try the next credential in the chain.
(#10488)1.4.0b1 (2020-03-10)DefaultAzureCredentialcan 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 raiseCredentialUnavailableErrorwhen they can't attempt to
authenticate due to missing data or state
(#9372)CertificateCredentialsupports password-protected private keys
(#9434)1.2.0 (2020-01-14)All credential pipelines includeProxyPolicy(#8945)Async credentials are async context managers and have an asyncclosemethod
(#9090)1.1.0 (2019-11-27)ConstructingDefaultAzureCredentialno longer raisesImportErroron Python
3.8 on Windows (8294)InteractiveBrowserCredentialraises when unable to open a web browser
(8465)InteractiveBrowserCredentialprompts for account selection
(8470)The credentials composingDefaultAzureCredentialare configurable by keyword
arguments (8514)SharedTokenCacheCredentialaccepts an optionaltenant_idkeyword argument
(8689)1.0.1 (2019-11-05)ClientCertificateCredentialuses application and tenant IDs correctly
(8315)InteractiveBrowserCredentialproperly caches tokens
(8352)Adopted msal 1.0.0 and msal-extensions 0.1.3
(8359)1.0.0 (2019-10-29)Breaking changes:Async credentials now default toaiohttpfor transport but the library does not require it as a dependency because the
async API is optional. To use async credentials, please installaiohttpor seeazure-core documentationfor information about customizing the transport.RenamedClientSecretCredentialparameter "secret" to "client_secret"All credentials withtenant_idandclient_idpositional parameters now accept them in that orderChanges toInteractiveBrowserCredentialparameterspositional parameterclient_idis now an optional keyword argument. If no value is provided,
the Azure CLI's client ID will be used.Optional keyword argumenttenantrenamedtenant_idChanges toDeviceCodeCredentialoptional positional parameterprompt_callbackis now a keyword argumentprompt_callback's third argument is now adatetimerepresenting the
expiration time of the device codeoptional keyword argumenttenantrenamedtenant_idChanges toManagedIdentityCredentialnow accepts no positional arguments, and only one keyword argument:client_idtransport configuration is now done through keyword arguments as
described inazure-coredocumentationFixes and improvements:Authenticating with a single sign-on shared with other Microsoft applications
only requires a username when multiple users have signed in
(#8095)DefaultAzureCredentialaccepts anauthoritykeyword argument, enabling
its use in national clouds
(#8154)Dependency changesAdoptedmsal_extensions0.1.2Constrainedmsalrequirement to >=0.4.1,
<1.0.01.0.0b4 (2019-10-07)New features:AuthorizationCodeCredentialauthenticates with a previously obtained
authorization code. See Microsoft Entra'sauthorization code documentationfor more information about this authentication flow.Multi-cloud support: client credentials accept the authority of an Azure Active
Directory authentication endpoint as anauthoritykeyword argument. Known
authorities are defined inazure.identity.KnownAuthorities. The default
authority is for Azure Public Cloud,login.microsoftonline.com(KnownAuthorities.AZURE_PUBLIC_CLOUD). An application running in Azure
Government would useKnownAuthorities.AZURE_GOVERNMENTinstead:from azure.identity import DefaultAzureCredential, KnownAuthorities
credential = DefaultAzureCredential(authority=KnownAuthorities.AZURE_GOVERNMENT)Breaking changes:Removedclient_secretparameter fromInteractiveBrowserCredentialFixes and improvements:UsernamePasswordCredentialcorrectly 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:SharedTokenCacheCredentialauthenticates 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.DefaultAzureCredentialincludesSharedTokenCacheCredentialwhen
the shared cache is available, and environment variableAZURE_USERNAMEis set. See theREADMEfor more information.Dependency changes:New dependency:msal-extensions0.1.11.0.0b2 (2019-08-05)Breaking changes:Removedazure.core.Configurationfrom the public API in preparation for a
revamped configuration API. Staticcreate_configmethods have been renamed_create_config, and will be removed in a future release.Dependency changes:Adoptedazure-core1.0.0b2If 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.0b1AdoptedMSAL0.4.1New dependency for Python 2.7:mockNew features:Added credentials for authenticating users:DeviceCodeCredentialInteractiveBrowserCredentialUsernamePasswordCredentialasync versions of these credentials will be added in a future release1.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 visithttps://aka.ms/azure-sdk-preview1-python.This release supports service principal and managed identity authentication.
See thedocumentationfor more details. User authentication will be added in an upcoming preview
release.This release supports only global Microsoft Entra tenants, i.e. those
using thehttps://login.microsoftonline.comauthentication endpoint.