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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.