Microsoft Azure Identity Library for Python
Project description
Azure Identity client library for Python
The Azure Identity library provides a set of credential classes for use with Azure SDK clients which support Azure Active Directory (AAD) token authentication. This library does not support Azure Active Directory B2C.
Source code | Package (PyPI) | API reference documentation | Azure Active Directory documentation
Getting started
Install the package
Install Azure Identity with pip:
pip install azure-identity
Prerequisites
- an Azure subscription
- Python 2.7 or 3.5.3+
Authenticating during local development
When debugging and executing code locally it is 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.
Authenticating via Visual Studio Code
DefaultAzureCredential and VisualStudioCodeCredential can authenticate as
the user signed in to Visual Studio Code's
Azure Account extension.
After installing the extension, sign in to Azure in Visual Studio Code by
pressing F1 to open the command palette and running the Azure: Sign In
command.
Authenticating via the Azure CLI
DefaultAzureCredential and AzureCliCredential can authenticate as the user
signed in to the Azure CLI. To sign in to the Azure CLI, run
az 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 login will use the device code
authentication flow. This can also be selected manually by running az login --use-device-code.
Key concepts
Credentials
A credential is a class which 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 are constructed, and use that credential to authenticate requests.
The Azure Identity library focuses on OAuth authentication with Azure Active Directory (AAD). It offers a variety of credential classes capable of acquiring an AAD access token. See Credential Classes below for a list of this library's credential classes.
DefaultAzureCredential
DefaultAzureCredential is appropriate for most applications which will run in
the Azure Cloud because it combines common production credentials with
development credentials. DefaultAzureCredential attempts to authenticate via
the following mechanisms in this order, stopping when one succeeds:
- Environment -
DefaultAzureCredentialwill read account information specified via environment variables and use it to authenticate. - Managed Identity - if the application is deployed to an Azure host with
Managed Identity enabled,
DefaultAzureCredentialwill authenticate with it. - Visual Studio Code - if a user has signed in to the Visual Studio Code Azure
Account extension,
DefaultAzureCredentialwill authenticate as that user. - Azure CLI - if a user has signed in via the Azure CLI
az logincommand,DefaultAzureCredentialwill authenticate as that user. - Azure PowerShell - if a user has signed in via Azure PowerShell's
Connect-AzAccountcommand,DefaultAzureCredentialwill authenticate as that user. - Interactive - if enabled,
DefaultAzureCredentialwill interactively authenticate a user via the default browser.
DefaultAzureCredential is intended to simplify getting started with the SDK 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.
Managed Identity
DefaultAzureCredential and ManagedIdentityCredential support
managed identity authentication
in any hosting environment which supports managed identities, such as (this list is not exhaustive):
- Azure Virtual Machines
- Azure App Service
- Azure Kubernetes Service
- Azure Cloud Shell
- Azure Arc
- Azure Service Fabric
Examples
The following examples are provided below:
- Authenticating with DefaultAzureCredential
- Defining a custom authentication flow with ChainedTokenCredential
- Async credentials
Authenticating with DefaultAzureCredential
This example demonstrates authenticating the BlobServiceClient from the
azure-storage-blob library using
DefaultAzureCredential.
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
default_credential = DefaultAzureCredential()
client = BlobServiceClient(account_url, credential=default_credential)
Enabling interactive authentication with DefaultAzureCredential
Interactive authentication is disabled in the DefaultAzureCredential by
default and can be enabled with a keyword argument:
DefaultAzureCredential(exclude_interactive_browser_credential=False)
When enabled, DefaultAzureCredential falls back to interactively
authenticating via the system's default web browser when no other credential is
available.
Specifying a user assigned managed identity for DefaultAzureCredential
Many Azure hosts allow the assignment of a user assigned managed identity. To
configure DefaultAzureCredential to authenticate a user assigned identity,
use the managed_identity_client_id keyword argument:
DefaultAzureCredential(managed_identity_client_id=client_id)
Alternatively, set the environment variable AZURE_CLIENT_ID to the identity's
client ID.
Defining a custom authentication flow with ChainedTokenCredential
DefaultAzureCredential is generally the quickest way to get started developing
applications for Azure. For more advanced scenarios,
ChainedTokenCredential links 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 which will attempt to
authenticate using managed identity, and fall back to authenticating via the
Azure CLI when a managed identity is unavailable. This example uses the
EventHubProducerClient from the azure-eventhub client library.
from azure.eventhub import EventHubProducerClient
from azure.identity import AzureCliCredential, ChainedTokenCredential, ManagedIdentityCredential
managed_identity = ManagedIdentityCredential()
azure_cli = AzureCliCredential()
credential_chain = ChainedTokenCredential(managed_identity, azure_cli)
client = EventHubProducerClient(namespace, eventhub_name, credential_chain)
Async credentials
This library includes an async API supported on Python 3.5+. To use the async credentials in azure.identity.aio, you must first install an async transport, such as aiohttp. See azure-core documentation for more information.
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)
Credential Classes
Authenticating Azure Hosted Applications
| credential | usage |
|---|---|
| DefaultAzureCredential | simplified authentication to get started developing applications for the Azure cloud |
| ChainedTokenCredential | define custom authentication flows composing multiple credentials |
| EnvironmentCredential | authenticate a service principal or user configured by environment variables |
| ManagedIdentityCredential | authenticate the managed identity of an Azure resource |
Authenticating Service Principals
| credential | usage |
|---|---|
| ClientSecretCredential | authenticate a service principal using a secret |
| CertificateCredential | authenticate a service principal using a certificate |
Authenticating Users
| credential | usage |
|---|---|
| InteractiveBrowserCredential | interactively authenticate a user with the default web browser |
| DeviceCodeCredential | interactively authenticate a user on a device with limited UI |
| UsernamePasswordCredential | authenticate a user with a username and password (does not support multi-factor authentication) |
Authenticating via Development Tools
| credential | usage |
|---|---|
| AzureCliCredential | authenticate as the user signed in to the Azure CLI |
| VisualStudioCodeCredential | authenticate as the user signed in to the Visual Studio Code Azure Account extension |
Environment Variables
DefaultAzureCredential and EnvironmentCredential can be configured with environment variables. Each type of authentication requires values for specific variables:
Service principal with secret
| variable name | value |
|---|---|
AZURE_CLIENT_ID |
id of an Azure Active Directory application |
AZURE_TENANT_ID |
id of the application's Azure Active Directory tenant |
AZURE_CLIENT_SECRET |
one of the application's client secrets |
Service principal with certificate
| variable name | value |
|---|---|
AZURE_CLIENT_ID |
id of an Azure Active Directory application |
AZURE_TENANT_ID |
id of the application's Azure Active Directory tenant |
AZURE_CLIENT_CERTIFICATE_PATH |
path to a PEM-encoded certificate file including private key (without password protection) |
Username and password
| variable name | value |
|---|---|
AZURE_CLIENT_ID |
id of an Azure Active Directory application |
AZURE_USERNAME |
a username (usually an email address) |
AZURE_PASSWORD |
that user's password |
Configuration 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.
Troubleshooting
Error Handling
Credentials raise CredentialUnavailableError when they're unable to attempt
authentication because they lack required data or state. For example,
EnvironmentCredential will raise 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 details on handling specific Azure Active Directory errors please refer to the Azure Active Directory 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 do not contain authentication secrets.
Detailed DEBUG level logging, including request/response bodies and header values, is not enabled by default. It can be enabled with the logging_enable argument, 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 steps
Client library support
Client and management libraries listed on the Azure SDK release page which support Azure AD authentication accept credentials from this library. You can learn more about using these libraries in their documentation, which is linked from the release page.
Provide Feedback
If you encounter bugs or have suggestions, please open an issue.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Release History
1.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_URLtoAZURE_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
CustomHookPolicyto 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 redundant
ChainedTokenCredentialandDefaultAzureCredentiallogging. 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
InteractiveBrowserCredentialkeyword 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 Fixed
azure.identity.aio.ManagedIdentityCredentialis an async context manager that closes its underlying transport session at the end of awithblock
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_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".
- When
CertificateCredentialandClientSecretCredentialsupport regional STS on Azure VMs by either keyword argumentregional_authorityor environment variableAZURE_REGIONAL_AUTHORITY_NAME. Seeazure.identity.RegionalAuthorityfor possible values. (#19301)- Upgraded minimum
azure-coreversion to 1.11.0 and minimummsalversion to 1.12.0 - After 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+.
Added
VisualStudioCodeCredentialgets 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
AzurePowerShellCredentialauthenticates 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)
Fixed
AzureCliCredentialraisesCredentialUnavailableErrorwhen the CLI times out, and kills timed out subprocesses- Reduced retry delay for
ManagedIdentityCredentialon 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.
- Removed property
AuthenticationRequiredError.error_details
Fixed
- Credentials consistently retry token requests after connection failures, or when instructed to by a Retry-After header
- ManagedIdentityCredential caches tokens correctly
Added
InteractiveBrowserCredentialfunctions 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
CertificateCredentialkeyword argumentcertificate_bytestocertificate_data -
Credentials accepting keyword arguments
allow_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.
Added
- New class
TokenCachePersistenceOptionsconfigures persistent caching - The
AuthenticationRequiredError.claimsproperty provides any additional claims required by a user credential'sauthenticate()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
InteractiveBrowserCredentialuses 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.0b2
Fixed
ManagedIdentityCredentialcorrectly parses responses from the current (preview) version of Azure ML managed identity (#15361)
1.5.0 (2020-11-11)
Breaking Changes
- Renamed optional
CertificateCredentialkeyword argumentsend_certificate(added in 1.5.0b1) tosend_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
authenticatemethod fromDeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredential - Removed
allow_unencrypted_cacheandenable_persistent_cachekeyword arguments fromCertificateCredential,ClientSecretCredential,DeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredential - Removed
disable_automatic_authenticationkeyword argument fromDeviceCodeCredentialandInteractiveBrowserCredential - Removed
allow_unencrypted_cachekeyword argument fromSharedTokenCacheCredential - Removed classes
AuthenticationRecordandAuthenticationRequiredError
- Removed
- Removed
identity_configkeyword argument fromManagedIdentityCredential(was added in 1.5.0b1)
Changed
DeviceCodeCredentialparameterclient_idis now optional. When not provided, the credential will authenticate users to an Azure development application. (#14354)- Credentials raise
ValueErrorwhen constructed with tenant IDs containing invalid characters (#14821) - Raised minimum msal version to 1.6.0
Added
Fixed
- Prevent
VisualStudioCodeCredentialusing 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)
Fixed
AzureCliCredential.get_tokencorrectly sets token expiration time, preventing clients from using expired tokens (#14345)
Changed
- Adopted msal-extensions 0.3.0 (#13107)
1.4.1 (2020-10-07)
Fixed
AzureCliCredential.get_tokencorrectly 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
ManagedIdentityCredentialsupports 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 in
azure.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 changes
- Removed
authentication_recordkeyword argument from the asyncSharedTokenCacheCredential, i.e.azure.identity.aio.SharedTokenCacheCredential
1.4.0 (2020-08-10)
Added
DefaultAzureCredentialuses the value of environment variableAZURE_CLIENT_IDto configure a user-assigned managed identity. (#10931)
Breaking Changes
- Renamed
VSCodeCredentialtoVisualStudioCodeCredential - 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
authenticatemethod fromDeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredential - Removed
allow_unencrypted_cacheandenable_persistent_cachekeyword arguments fromCertificateCredential,ClientSecretCredential,DeviceCodeCredential,InteractiveBrowserCredential, andUsernamePasswordCredential - Removed
disable_automatic_authenticationkeyword argument fromDeviceCodeCredentialandInteractiveBrowserCredential - Removed
allow_unencrypted_cachekeyword argument fromSharedTokenCacheCredential - Removed classes
AuthenticationRecordandAuthenticationRequiredError - Removed
identity_configkeyword argument fromManagedIdentityCredential
- Removed
1.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.- Renamed
AuthenticationRecord.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 minimum
msalversion to 1.3.0 - The async
AzureCliCredentialcorrectly invokes/bin/sh(#12048)
1.4.0b5 (2020-06-12)
- Prevent an error on importing
AzureCliCredentialon 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 constructing
DefaultAzureCredential, 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 to
DeviceCodeCredentialandInteractiveBrowserCredentialin 1.4.0b3 is available onUsernamePasswordCredentialas well. (#11449) - The optional persistent cache for
DeviceCodeCredentialandInteractiveBrowserCredentialadded 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 argumentallow_unencrypted_cache=True.
- On Linux, the persistent cache requires libsecret and
1.4.0b3 (2020-05-04)
EnvironmentCredentialcorrectly initializesUsernamePasswordCredentialwith the value ofAZURE_TENANT_ID(#11127)- Values for the constructor keyword argument
authorityandAZURE_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 with
DeviceCodeCredentialandInteractiveBrowserCredential(#10612)- new method
authenticateinteractively authenticates a user, returns a serializableAuthenticationRecord - new constructor keyword arguments
authentication_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.
- new method
- Now
DefaultAzureCredentialcan authenticate with the identity signed in to Visual Studio Code's Azure extension. (#10472)
1.4.0b2 (2020-04-06)
- After an instance of
DefaultAzureCredentialsuccessfully 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_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 variable
AZURE_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 raise
CredentialUnavailableErrorwhen 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 include
ProxyPolicy(#8945) - Async credentials are async context managers and have an async
closemethod (#9090)
1.1.0 (2019-11-27)
- Constructing
DefaultAzureCredentialno longer raisesImportErroron Python 3.8 on Windows (8294) InteractiveBrowserCredentialraises when unable to open a web browser (8465)InteractiveBrowserCredentialprompts for account selection (8470)- The credentials composing
DefaultAzureCredentialare 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 to
aiohttpfor transport but the library does not require it as a dependency because the async API is optional. To use async credentials, please installaiohttpor see azure-core documentation for information about customizing the transport. - Renamed
ClientSecretCredentialparameter "secret" to "client_secret" - All credentials with
tenant_idandclient_idpositional parameters now accept them in that order - Changes to
InteractiveBrowserCredentialparameters- positional parameter
client_idis now an optional keyword argument. If no value is provided, the Azure CLI's client ID will be used. - Optional keyword argument
tenantrenamedtenant_id
- positional parameter
- Changes to
DeviceCodeCredential- optional positional parameter
prompt_callbackis now a keyword argument prompt_callback's third argument is now adatetimerepresenting the expiration time of the device code- optional keyword argument
tenantrenamedtenant_id
- optional positional parameter
- Changes to
ManagedIdentityCredential- now accepts no positional arguments, and only one keyword argument:
client_id - transport configuration is now done through keyword arguments as
described in
azure-coredocumentation
- now accepts no positional arguments, and only one keyword argument:
Fixes 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 changes
- Adopted
msal_extensions0.1.2 - Constrained
msalrequirement to >=0.4.1, <1.0.0
1.0.0b4 (2019-10-07)
New features:
AuthorizationCodeCredentialauthenticates with a previously obtained authorization code. See Azure Active Directory'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
authoritykeyword 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:
- Removed
client_secretparameter fromInteractiveBrowserCredential
Fixes 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 the README for more information.
Dependency changes:
- New dependency:
msal-extensions0.1.1
1.0.0b2 (2019-08-05)
Breaking changes:
- Removed
azure.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:
- Adopted azure-core 1.0.0b2
- 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
- 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:
- Adopted MSAL 0.4.1
- New dependency for Python 2.7: mock
New features:
- Added credentials for authenticating users:
DeviceCodeCredentialInteractiveBrowserCredentialUsernamePasswordCredential- 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 Azure Active Directory tenants, i.e. those using the https://login.microsoftonline.com authentication endpoint.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure-identity-1.6.1.zip.
File metadata
- Download URL: azure-identity-1.6.1.zip
- Upload date:
- Size: 248.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69035c81f280fac5fa9c55f87be3a359b264853727486e3568818bb43988080e
|
|
| MD5 |
ec58ec4cfc7433cd273b91b8162c0b6d
|
|
| BLAKE2b-256 |
a8206dcb10fdbce9d6c22fdc401ee0b825c751125ad078d49b2750eb6aeb0050
|
File details
Details for the file azure_identity-1.6.1-py2.py3-none-any.whl.
File metadata
- Download URL: azure_identity-1.6.1-py2.py3-none-any.whl
- Upload date:
- Size: 109.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f4f8c1ba2887cf3e1663be324fde278fce52d781123ad95c07d2c9d9cdeef5a
|
|
| MD5 |
ebcb057a7c98c3249910f764bb0bb4dc
|
|
| BLAKE2b-256 |
45f202c13cb4be880681c63890955fb87b2eb072393ce54102af66fdb8c10088
|