Trait OAuthClient

Source
pub trait OAuthClient {
    // Required methods
    fn get_client(&self) -> Result<BasicClient, OauthError>;
    fn get_state(&self) -> Option<StateAuth>;
    fn generate_url<'async_trait, F, Fut>(
        self,
        scopes: Vec<String>,
        save: F,
    ) -> Pin<Box<dyn Future<Output = Result<Box<Self>, OauthError>> + Send + 'async_trait>>
       where F: FnOnce(StateAuth) -> Fut + Send + 'async_trait,
             Fut: Future<Output = ()> + Send + 'async_trait,
             Self: 'async_trait;
    fn generate_token<'life0, 'async_trait>(
        &'life0 self,
        code: String,
        verifier: String,
    ) -> Pin<Box<dyn Future<Output = Result<String, OauthError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

OAuthClient is the main struct of the lib, it will handle all the connection with the provider

Required Methods§

Source

fn get_client(&self) -> Result<BasicClient, OauthError>

Source

fn get_state(&self) -> Option<StateAuth>

Get fields data from generated URL

§Return

StateAuth - The state, verifier and url_generated

Source

fn generate_url<'async_trait, F, Fut>( self, scopes: Vec<String>, save: F, ) -> Pin<Box<dyn Future<Output = Result<Box<Self>, OauthError>> + Send + 'async_trait>>
where F: FnOnce(StateAuth) -> Fut + Send + 'async_trait, Fut: Future<Output = ()> + Send + 'async_trait, Self: 'async_trait,

Generate the URL to redirect the user to the provider

§Arguments
  • scopes - Vec - The scopes that you want to access in the provider
  • save - F - The function that will use to save your state in the db/memory
Source

fn generate_token<'life0, 'async_trait>( &'life0 self, code: String, verifier: String, ) -> Pin<Box<dyn Future<Output = Result<String, OauthError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate the token from the code and verifier

§Arguments
  • code - String - The code that the provider will return after the user accept the auth
  • verifier - String - The verifier that was generated in the first step
§Return

The token generated

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§