pub struct OAuth2Client { /* private fields */ }Expand description
OAuth2 client for handling authorization flows
Similar to Spring Security’s OAuth2AuthorizedClientService.
Implementations§
Source§impl OAuth2Client
impl OAuth2Client
Sourcepub async fn new(config: OAuth2Config) -> Result<Self, OAuth2Error>
pub async fn new(config: OAuth2Config) -> Result<Self, OAuth2Error>
Create a new OAuth2 client from configuration
For OIDC providers, this will perform discovery to fetch provider metadata.
Sourcepub fn new_basic(config: OAuth2Config) -> Result<Self, OAuth2Error>
pub fn new_basic(config: OAuth2Config) -> Result<Self, OAuth2Error>
Create a new OAuth2 client without OIDC discovery (sync)
Use this when you don’t need OIDC features or want to avoid async initialization.
Generate an authorization URL for the OAuth2 flow
Returns (authorization_url, state, pkce_verifier, nonce)
Sourcepub async fn exchange_code(
&self,
code: &str,
pkce_verifier: Option<PkceCodeVerifier>,
nonce: Option<&Nonce>,
) -> Result<(OAuth2User, Option<OidcUser>), OAuth2Error>
pub async fn exchange_code( &self, code: &str, pkce_verifier: Option<PkceCodeVerifier>, nonce: Option<&Nonce>, ) -> Result<(OAuth2User, Option<OidcUser>), OAuth2Error>
Exchange authorization code for tokens
Sourcepub fn config(&self) -> &OAuth2Config
pub fn config(&self) -> &OAuth2Config
Get the configuration
Trait Implementations§
Source§impl Clone for OAuth2Client
impl Clone for OAuth2Client
Source§fn clone(&self) -> OAuth2Client
fn clone(&self) -> OAuth2Client
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for OAuth2Client
impl RefUnwindSafe for OAuth2Client
impl Send for OAuth2Client
impl Sync for OAuth2Client
impl Unpin for OAuth2Client
impl UnwindSafe for OAuth2Client
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more