Struct aws_config::meta::token::TokenProviderChain
source · pub struct TokenProviderChain { /* private fields */ }
Expand description
Access token provider that checks a series of inner providers.
Each provider will be evaluated in order:
- If a provider returns valid
Token
they will be returned immediately. No other token providers will be used. - Otherwise, if a provider returns
TokenError::TokenNotLoaded
, the next provider will be checked. - Finally, if a provider returns any other error condition, an error will be returned immediately.
§Examples
use aws_config::meta::token::TokenProviderChain;
use aws_config::profile::ProfileFileTokenProvider;
use aws_credential_types::Token;
let provider = TokenProviderChain::first_try("Profile", ProfileFileTokenProvider::builder().build())
.or_else("Static", Token::new("example", None));
Implementations§
source§impl TokenProviderChain
impl TokenProviderChain
sourcepub fn first_try(
name: impl Into<Cow<'static, str>>,
provider: impl ProvideToken + 'static
) -> Self
pub fn first_try( name: impl Into<Cow<'static, str>>, provider: impl ProvideToken + 'static ) -> Self
Create a TokenProviderChain
that begins by evaluating this provider
sourcepub fn or_else(
self,
name: impl Into<Cow<'static, str>>,
provider: impl ProvideToken + 'static
) -> Self
pub fn or_else( self, name: impl Into<Cow<'static, str>>, provider: impl ProvideToken + 'static ) -> Self
Add a fallback provider to the token provider chain
sourcepub async fn or_default_provider(self) -> Self
Available on crate feature sso
only.
pub async fn or_default_provider(self) -> Self
sso
only.Add a fallback to the default provider chain
sourcepub async fn default_provider() -> Self
Available on crate feature sso
only.
pub async fn default_provider() -> Self
sso
only.Creates a token provider chain that starts with the default provider
Trait Implementations§
source§impl Debug for TokenProviderChain
impl Debug for TokenProviderChain
source§impl ProvideToken for TokenProviderChain
impl ProvideToken for TokenProviderChain
source§fn provide_token<'a>(&'a self) -> ProvideToken<'_>where
Self: 'a,
fn provide_token<'a>(&'a self) -> ProvideToken<'_>where
Self: 'a,
Returns a future that provides an access token.
Auto Trait Implementations§
impl Freeze for TokenProviderChain
impl !RefUnwindSafe for TokenProviderChain
impl Send for TokenProviderChain
impl Sync for TokenProviderChain
impl Unpin for TokenProviderChain
impl !UnwindSafe for TokenProviderChain
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Creates a shared type from an unshared type.