SharedTokenCacheCredential Class

Authenticates using tokens in the local cache shared between Microsoft applications.

Inheritance
azure.identity._internal.shared_token_cache.SharedTokenCacheBase
SharedTokenCacheCredential

Constructor

SharedTokenCacheCredential(username=None, **kwargs)

Parameters

username
str
Required

Username (typically an email address) of the user to authenticate as. This is used when the local cache contains tokens for multiple identities.

authority
str
Required

Authority of an Azure Active Directory endpoint, for example 'login.microsoftonline.com', the authority for Azure Public Cloud (which is the default). AzureAuthorityHosts defines authorities for other clouds.

tenant_id
str
Required

an Azure Active Directory tenant ID. Used to select an account when the cache contains tokens for multiple identities.

authentication_record
<xref:AuthenticationRecord>
Required

an authentication record returned by a user credential such as DeviceCodeCredential or InteractiveBrowserCredential

cache_persistence_options
TokenCachePersistenceOptions
Required

configuration for persistent token caching. If not provided, the credential will use the persistent cache shared by Microsoft development applications

Methods

get_token

Get an access token for scopes from the shared cache.

If no access token is cached, attempt to acquire one using a cached refresh token.

This method is called automatically by Azure SDK clients.

get_token

Get an access token for scopes from the shared cache.

If no access token is cached, attempt to acquire one using a cached refresh token.

This method is called automatically by Azure SDK clients.

get_token(*scopes, **kwargs)

Parameters

scopes
str
Required

desired scopes for the access token. This method requires at least one scope.

claims
str

additional claims required in the token, such as those returned in a resource provider's claims challenge following an authorization failure

Return type

Exceptions

~azure.identity.CredentialUnavailableError

the cache is unavailable or contains insufficient user information

~azure.core.exceptions.ClientAuthenticationError

authentication failed. The error's message attribute gives a reason.