Skip to main content

auto_refresh_token

Function auto_refresh_token 

Source
pub async fn auto_refresh_token<F, Fut>(
    token: &mut TokenData,
    refresh: F,
) -> Result<()>
where F: FnOnce() -> Fut, Fut: Future<Output = Result<TokenData>>,
Expand description

Check if a token is expired and refresh it if needed.

Calls refresh only when token.is_expired() returns true. The caller is responsible for persisting the new token.