Skip to main content

CredentialRenewal

Trait CredentialRenewal 

Source
pub trait CredentialRenewal:
    Debug
    + Send
    + Sync {
    // Required method
    fn renew<'life0, 'life1, 'async_trait>(
        &'life0 self,
        refresh_token: &'life1 SecretString,
    ) -> Pin<Box<dyn Future<Output = Result<UserAccessToken, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

How a credential replaces itself.

§Why this is a port rather than a method

Renewal is two acts that must happen in one order: exchange the refresh token with GitHub, then persist the new pair before anything uses it. GitHub rotates on use – the old pair dies the instant the new one is issued – so a response that is used but not stored leaves the host holding a credential it will forget, and the one it forgot is already dead. There is no retry: a spent refresh token answers incorrect_client_credentials, a message about the client id and secret that is about neither.

The exchange belongs to c2 and the store belongs to d2, and this crate owns neither. So the ordering lives with whoever implements this, in one place, rather than being a rule each caller has to remember.

Required Methods§

Source

fn renew<'life0, 'life1, 'async_trait>( &'life0 self, refresh_token: &'life1 SecretString, ) -> Pin<Box<dyn Future<Output = Result<UserAccessToken, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Exchange refresh_token for a fresh pair and persist it.

§Errors

Any failure; the caller treats every one the same way, by keeping the credential it has and letting the next 401 try again.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§