Skip to main content

RefreshTokenStore

Trait RefreshTokenStore 

Source
pub trait RefreshTokenStore: Send + Sync {
    // Required method
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 self,
        refresh_token: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A durable store for the rotating OAuth refresh token. Box invalidates the previous refresh token on each exchange, so an app that restarts must reload the newest one — implement this to persist each rotation (a file, a DB row, a secret manager).

save is async so a store can do real I/O without blocking the executor (do the I/O with async APIs, or offload sync work via tokio::task::spawn_blocking). It runs before a freshly rotated token is returned; its failure propagates on the rotating call, and the runtime keeps retrying persistence on later calls until it succeeds, so a rotation is never silently treated as durable when it is not.

Required Methods§

Source

fn save<'life0, 'life1, 'async_trait>( &'life0 self, refresh_token: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persist the newly rotated refresh token durably.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§