pub struct EnvironmentCredential { /* private fields */ }Expand description
Authenticates a service principal configured entirely by environment
variables, via the client-secret flow: AZURE_TENANT_ID,
AZURE_CLIENT_ID, AZURE_CLIENT_SECRET.
A restricted port of azure_identity’s EnvironmentCredential: upstream
also supports a certificate flow and a (deprecated) username/password
flow, neither of which this crate implements, so only the client-secret
configuration is recognized. Unlike upstream — which defers the
“not configured” failure to the first
get_token call — new fails
immediately, listing every missing variable, so misconfiguration is caught
at startup rather than on first use.
Implementations§
Source§impl EnvironmentCredential
impl EnvironmentCredential
Sourcepub fn new(scope: impl Into<String>) -> Result<Self>
pub fn new(scope: impl Into<String>) -> Result<Self>
Read AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_CLIENT_SECRET
from the environment and build a client-secret credential acquiring
tokens for scope.
§Errors
Error::Configuration naming every missing variable, when one or
more of the three are unset.
Override the Entra authority used by the inner client-secret
credential (default DEFAULT_AUTHORITY).
Trait Implementations§
Source§impl TokenCredential for EnvironmentCredential
impl TokenCredential for EnvironmentCredential
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