pub enum BearerAuthenticator {
Ephemeral {
inner: EphemeralBearerAuthenticator,
},
Static {
inner: StaticBearerAuthenticator,
},
}Expand description
A BearerAuthenticator (1) stores existing fresh auth tokens and (2)
authenticates and fetches new auth tokens when they expire.
Variants§
Implementations§
Source§impl BearerAuthenticator
impl BearerAuthenticator
Sourcepub fn new(
user_key_pair: KeyPair,
maybe_token: Option<TokenWithExpiration>,
) -> Self
pub fn new( user_key_pair: KeyPair, maybe_token: Option<TokenWithExpiration>, ) -> Self
Create a new BearerAuthenticator with the auth api handle, the
user_key_pair (for signing auth requests), and an optional existing
token.
Sourcepub fn new_with_scope(
user_key_pair: KeyPair,
maybe_token: Option<TokenWithExpiration>,
scope: Option<Scope>,
) -> Self
pub fn new_with_scope( user_key_pair: KeyPair, maybe_token: Option<TokenWithExpiration>, scope: Option<Scope>, ) -> Self
BearerAuthenticator::new constructor with an optional scope to
restrict requested auth tokens.
Sourcepub fn new_static_token(token: BearerAuthToken) -> Self
pub fn new_static_token(token: BearerAuthToken) -> Self
A BearerAuthenticator that always returns the same static,
long-lived token.
pub fn user_key_pair(&self) -> Option<&KeyPair>
Sourcepub async fn get_token<T: BearerAuthBackendApi + ?Sized>(
&self,
api: &T,
now: SystemTime,
) -> Result<BearerAuthToken, BackendApiError>
pub async fn get_token<T: BearerAuthBackendApi + ?Sized>( &self, api: &T, now: SystemTime, ) -> Result<BearerAuthToken, BackendApiError>
Try to either (1) return an existing, fresh token or (2) authenticate with the backend to get a new fresh token (and cache it).
Sourcepub async fn get_token_with_exp<T: BearerAuthBackendApi + ?Sized>(
&self,
api: &T,
now: SystemTime,
) -> Result<TokenWithExpiration, BackendApiError>
pub async fn get_token_with_exp<T: BearerAuthBackendApi + ?Sized>( &self, api: &T, now: SystemTime, ) -> Result<TokenWithExpiration, BackendApiError>
Try to either (1) return an existing, fresh token or (2) authenticate with the backend to get a new fresh token (and cache it). Also returns the token’s expiration time.
Auto Trait Implementations§
impl !Freeze for BearerAuthenticator
impl !RefUnwindSafe for BearerAuthenticator
impl Send for BearerAuthenticator
impl Sync for BearerAuthenticator
impl Unpin for BearerAuthenticator
impl UnsafeUnpin for BearerAuthenticator
impl UnwindSafe for BearerAuthenticator
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