pub struct TokenSource { /* private fields */ }Expand description
A source of bearer tokens, consulted immediately before each authenticated request.
A source wraps an async closure, so any function can supply credentials. The providers in
this crate convert into one with From. Clones share the closure.
Implementations§
Source§impl TokenSource
impl TokenSource
Sourcepub fn new<F, Fut>(token: F) -> Self
pub fn new<F, Fut>(token: F) -> Self
A source that calls token before each request. token returns None when it has no
credentials to offer.
Sourcepub fn with_cached<F, Fut>(self, cached: F) -> Self
pub fn with_cached<F, Fut>(self, cached: F) -> Self
Answer cached_token with cached, which must neither make
network requests nor prompt.
Sourcepub async fn token(&self) -> CredentialResult<Option<Token>>
pub async fn token(&self) -> CredentialResult<Option<Token>>
A usable token, or None when this source has no credentials to offer.
Sourcepub async fn cached_token(&self) -> CredentialResult<Option<Token>>
pub async fn cached_token(&self) -> CredentialResult<Option<Token>>
A token this source already holds, without network requests or prompts.
Trait Implementations§
Source§impl Clone for TokenSource
impl Clone for TokenSource
Source§impl Debug for TokenSource
impl Debug for TokenSource
Source§impl From<ClientCredentialsProvider> for TokenSource
impl From<ClientCredentialsProvider> for TokenSource
Source§fn from(provider: ClientCredentialsProvider) -> Self
fn from(provider: ClientCredentialsProvider) -> Self
Converts to this type from the input type.
Source§impl From<CredentialChain> for TokenSource
impl From<CredentialChain> for TokenSource
Source§fn from(provider: CredentialChain) -> Self
fn from(provider: CredentialChain) -> Self
Converts to this type from the input type.
Source§impl From<FallbackAuthn> for TokenSource
impl From<FallbackAuthn> for TokenSource
Source§fn from(provider: FallbackAuthn) -> Self
fn from(provider: FallbackAuthn) -> Self
Converts to this type from the input type.
Source§impl From<OidcAuthProvider> for TokenSource
impl From<OidcAuthProvider> for TokenSource
Source§fn from(provider: OidcAuthProvider) -> Self
fn from(provider: OidcAuthProvider) -> Self
Converts to this type from the input type.
Source§impl From<RefreshingAuthTokenProvider> for TokenSource
impl From<RefreshingAuthTokenProvider> for TokenSource
Source§fn from(provider: RefreshingAuthTokenProvider) -> Self
fn from(provider: RefreshingAuthTokenProvider) -> Self
Converts to this type from the input type.
Source§impl From<WorkloadAuthn> for TokenSource
impl From<WorkloadAuthn> for TokenSource
Source§fn from(provider: WorkloadAuthn) -> Self
fn from(provider: WorkloadAuthn) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for TokenSource
impl !UnwindSafe for TokenSource
impl Freeze for TokenSource
impl Send for TokenSource
impl Sync for TokenSource
impl Unpin for TokenSource
impl UnsafeUnpin for TokenSource
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