pub struct DefaultAzureCredential { /* private fields */ }Expand description
A prebuilt ChainedTokenCredential, in (a subset of) azure_identity’s
documented DefaultAzureCredential order.
Upstream (Python/.NET) DefaultAzureCredential tries, in order:
EnvironmentCredential, WorkloadIdentityCredential,
ManagedIdentityCredential, SharedTokenCacheCredential (Windows only),
VisualStudioCodeCredential, AzureCliCredential,
AzurePowerShellCredential, AzureDeveloperCliCredential, and
(Windows/WSL only, off by default) InteractiveBrowserCredential/broker
authentication.
This crate implements four of those credential types, so this chain is
EnvironmentCredential → WorkloadIdentityCredential →
ManagedIdentityCredential → AzureCliCredential — the same relative
order upstream uses among the credentials that exist here. Every other
link in upstream’s list (the shared token cache, IDE-signed-in
credentials, PowerShell, the Azure Developer CLI, interactive/broker auth)
is simply absent rather than approximated by something else; callers that
need one of those should build their own ChainedTokenCredential.
EnvironmentCredential and WorkloadIdentityCredential are included only
when their required environment variables are present — construction
failure just excludes them from the chain, mirroring upstream’s
“unavailable credentials are skipped, not fatal” behavior (there, via a
placeholder that defers the error to get_token; here, by omission, since
ChainedTokenCredential already only holds constructed credentials).
ManagedIdentityCredential and AzureCliCredential need no such
configuration and are always present, so the chain is never empty. As with
any ChainedTokenCredential, whichever credential first returns a token
is remembered and tried first on subsequent calls.
Implementations§
Trait Implementations§
Source§impl TokenCredential for DefaultAzureCredential
impl TokenCredential for DefaultAzureCredential
Source§fn get_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_token<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Authorization: Bearer <token>.Source§fn get_token_for_scope<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_for_scope<'life0, 'life1, 'async_trait>(
&'life0 self,
scope: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
scope (audience), e.g.
"https://ai.azure.com/.default". Read more