pub struct OAuth2Flow<P: OAuthProvider, M: UserMapper = ()> { /* private fields */ }Expand description
Orchestrates the standard OAuth2 Authorization Code flow.
Implementations§
Source§impl<P: OAuthProvider> OAuth2Flow<P, ()>
impl<P: OAuthProvider> OAuth2Flow<P, ()>
Source§impl<P: OAuthProvider, M: UserMapper> OAuth2Flow<P, M>
impl<P: OAuthProvider, M: UserMapper> OAuth2Flow<P, M>
Sourcepub fn with_mapper(provider: P, mapper: M) -> Self
pub fn with_mapper(provider: P, mapper: M) -> Self
Create a new OAuth2Flow with the given provider and user mapper.
Sourcepub fn initiate_login(
&self,
scopes: &[&str],
pkce_challenge: Option<&str>,
) -> (String, String)
pub fn initiate_login( &self, scopes: &[&str], pkce_challenge: Option<&str>, ) -> (String, String)
Generates the redirect URL and CSRF state.
Sourcepub async fn finalize_login(
&self,
code: &str,
received_state: &str,
expected_state: &str,
pkce_verifier: Option<&str>,
) -> Result<(Identity, OAuthToken, Option<M::LocalUser>), AuthError>
pub async fn finalize_login( &self, code: &str, received_state: &str, expected_state: &str, pkce_verifier: Option<&str>, ) -> Result<(Identity, OAuthToken, Option<M::LocalUser>), AuthError>
Completes the flow by exchanging the code. If a mapper is provided, it will also map the identity to a local user.
Sourcepub async fn refresh_access_token(
&self,
refresh_token: &str,
) -> Result<OAuthToken, AuthError>
pub async fn refresh_access_token( &self, refresh_token: &str, ) -> Result<OAuthToken, AuthError>
Refresh an access token using a refresh token.
Trait Implementations§
Source§impl<P: OAuthProvider, M: UserMapper> ErasedOAuthFlow for OAuth2Flow<P, M>
impl<P: OAuthProvider, M: UserMapper> ErasedOAuthFlow for OAuth2Flow<P, M>
Source§fn provider_id(&self) -> String
fn provider_id(&self) -> String
Get the provider identifier.
Source§fn initiate_login(
&self,
scopes: &[&str],
pkce_challenge: Option<&str>,
) -> (String, String)
fn initiate_login( &self, scopes: &[&str], pkce_challenge: Option<&str>, ) -> (String, String)
Generates the redirect URL and CSRF state.
Source§fn finalize_login<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
code: &'life1 str,
received_state: &'life2 str,
expected_state: &'life3 str,
pkce_verifier: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(Identity, OAuthToken), AuthError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn finalize_login<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
code: &'life1 str,
received_state: &'life2 str,
expected_state: &'life3 str,
pkce_verifier: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<(Identity, OAuthToken), AuthError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Completes the flow by exchanging the code.
Auto Trait Implementations§
impl<P, M> Freeze for OAuth2Flow<P, M>
impl<P, M> RefUnwindSafe for OAuth2Flow<P, M>where
P: RefUnwindSafe,
M: RefUnwindSafe,
impl<P, M> Send for OAuth2Flow<P, M>
impl<P, M> Sync for OAuth2Flow<P, M>
impl<P, M> Unpin for OAuth2Flow<P, M>
impl<P, M> UnwindSafe for OAuth2Flow<P, M>where
P: UnwindSafe,
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more