Skip to main content

TokenSource

Trait TokenSource 

Source
pub trait TokenSource:
    Send
    + Sync
    + Debug {
    // Required method
    fn fetch_bearer(
        &self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + '_>>;
}
Expand description

A source of bearer tokens for request authentication.

Implemented by canton_auth::TokenProvider (OIDC client-credentials with caching + refresh). Object-safe by design: Auth::Dynamic stores it as an Arc<dyn TokenSource>.

Required Methods§

Source

fn fetch_bearer( &self, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + '_>>

Resolve the current bearer token (fetching/refreshing as needed), or None for an unauthenticated call.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TokenSource for TokenProvider

Lets a TokenProvider back the SDK’s shared canton_core::Auth without canton-core depending on this crate: Config::with_oidc(provider) stores it as an Arc<dyn TokenSource>.

Source§

fn fetch_bearer( &self, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, Error>> + Send + '_>>

Implementors§