pub struct TokenManager { /* private fields */ }Expand description
Exchanges an API token for short-lived JWTs and keeps them fresh.
A credential that already looks like a JWT (eyJ prefix) is passed through
unchanged, as is any credential when HOTDATA_DISABLE_JWT_EXCHANGE is set
to an affirmative value; every other (opaque) API token is exchanged.
Implementations§
Source§impl TokenManager
impl TokenManager
Sourcepub fn new(
credential: impl Into<String>,
client: Client,
base_path: impl Into<String>,
) -> Self
pub fn new( credential: impl Into<String>, client: Client, base_path: impl Into<String>, ) -> Self
Build a token manager.
credential– the user’s API token (or a literaleyJ...JWT).client– the SDK’s configured reqwest client; cloned in so the exchange reuses the same TLS/proxy/connection pool.base_path– the API base URL (e.g.https://api.hotdata.dev);/v1/auth/jwtis appended at mint time.
Sourcepub fn with_options(
credential: impl Into<String>,
client: Client,
opts: TokenManagerOptions,
) -> Self
pub fn with_options( credential: impl Into<String>, client: Client, opts: TokenManagerOptions, ) -> Self
Build a token manager with explicit TokenManagerOptions.
Equivalent to TokenManager::new when opts is Default::default()
with base_path set. Use this to override the mint attribution
(client_id/token_path), seed an existing JWT or refresh token, or
install an on_persist callback that survives rotation across process
invocations.
credential– the user’s API token (or a literaleyJ...JWT).client– the SDK’s configured reqwest client; cloned in so the exchange reuses the same TLS/proxy/connection pool.opts– mint attribution, seed values, and persistence callback.
Trait Implementations§
Source§impl BearerTokenProvider for TokenManager
impl BearerTokenProvider for TokenManager
Source§fn bearer_value<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, TokenExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn bearer_value<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, TokenExchangeError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the bearer token to put on the wire for the next request.
Auto Trait Implementations§
impl !Freeze for TokenManager
impl !RefUnwindSafe for TokenManager
impl !UnwindSafe for TokenManager
impl Send for TokenManager
impl Sync for TokenManager
impl Unpin for TokenManager
impl UnsafeUnpin for TokenManager
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