Skip to main content

AuthProvider

Trait AuthProvider 

Source
pub trait AuthProvider: Send + Sync {
    // Required methods
    fn provider_name(&self) -> &str;
    fn exchange_code<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        code: &'life1 str,
        redirect_uri: Option<&'life2 str>,
        auth_config: &'life3 AuthType,
        pkce_code_verifier: Option<&'life4 str>,
    ) -> Pin<Box<dyn Future<Output = Result<AuthSession, AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait;
    fn refresh_token<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        refresh_token: &'life1 str,
        auth_config: &'life2 AuthType,
    ) -> Pin<Box<dyn Future<Output = Result<AuthSession, AuthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn build_auth_url(
        &self,
        auth_config: &AuthType,
        state: &str,
        scopes: &[String],
        redirect_uri: Option<&str>,
    ) -> Result<String, AuthError>;
}
Expand description

Authentication provider trait for different OAuth2 providers

Required Methods§

Source

fn provider_name(&self) -> &str

Provider name (e.g., “google”, “github”, “twitter”)

Source

fn exchange_code<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, code: &'life1 str, redirect_uri: Option<&'life2 str>, auth_config: &'life3 AuthType, pkce_code_verifier: Option<&'life4 str>, ) -> Pin<Box<dyn Future<Output = Result<AuthSession, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait,

Exchange authorization code for access token

Source

fn refresh_token<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, refresh_token: &'life1 str, auth_config: &'life2 AuthType, ) -> Pin<Box<dyn Future<Output = Result<AuthSession, AuthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Refresh an access token

Source

fn build_auth_url( &self, auth_config: &AuthType, state: &str, scopes: &[String], redirect_uri: Option<&str>, ) -> Result<String, AuthError>

Build authorization URL

Implementors§