SharedTokenCacheCredential Class
Authenticates using tokens in the local cache shared between Microsoft applications.
- Inheritance
-
azure.identity._internal.shared_token_cache.SharedTokenCacheBaseSharedTokenCacheCredentialazure.identity.aio._internal.AsyncContextManagerSharedTokenCacheCredential
Constructor
SharedTokenCacheCredential(username: Optional[str] = None, **kwargs: Any)
Parameters
- username
- str
Username (typically an email address) of the user to authenticate as. This is required because the local cache may contain tokens for multiple identities.
- authority
- str
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
an Azure Active Directory tenant ID. Used to select an account when the cache contains tokens for multiple identities.
- cache_persistence_options
- TokenCachePersistenceOptions
configuration for persistent token caching. If not provided, the credential will use the persistent cache shared by Microsoft development applications
Methods
| close |
Close the credential's transport session. |
| 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. |
close
Close the credential's transport session.
async close()
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.
async get_token(*scopes: str, **kwargs: Any) -> AccessToken
Parameters
- tenant_id
- str
optional tenant to include in the token request.
Return type
Exceptions
the cache is unavailable or contains insufficient user information
authentication failed. The error's message attribute gives a reason. Any error response from Azure Active Directory is available as the error's response attribute.
Feedback
Submit and view feedback for