pub struct AuthorizationCodeGrant {
    pub scopes: Vec<Scope>,
    pub pkce: Option<(PkceCodeChallenge, PkceCodeVerifier)>,
    pub redirect_host: String,
    pub redirect_port: u16,
}
Expand description

OAuth 2.0 Authorization Code Grant flow builder.

The first step (once the builder is configured) is to build a [crate::Client].

The second step is to get the redirect URL by calling AuthorizationCodeGrant::get_redirect_url.

The last step is to spawn a redirect server and wait for the user to click on the redirect URL in order to extract the access token and the refresh token by calling AuthorizationCodeGrant::wait_for_redirection.

Fields§

§scopes: Vec<Scope>§pkce: Option<(PkceCodeChallenge, PkceCodeVerifier)>§redirect_host: String§redirect_port: u16

Implementations§

source§

impl AuthorizationCodeGrant

source

pub fn new() -> Self

source

pub fn with_scope<T>(self, scope: T) -> Self
where T: ToString,

source

pub fn with_pkce(self) -> Self

source

pub fn with_redirect_host<T>(self, host: T) -> Self
where T: ToString,

source

pub fn with_redirect_port<T>(self, port: T) -> Self
where T: Into<u16>,

source

pub fn get_redirect_url(&self, client: &BasicClient) -> (Url, CsrfToken)

Generate the redirect URL used to complete the OAuth 2.0 Authorization Code Grant flow.

source

pub async fn wait_for_redirection( self, client: &BasicClient, csrf_state: CsrfToken ) -> Result<(String, Option<String>)>

Wait for the user to click on the redirect URL generated by AuthorizationCodeGrant::get_redirect_url, then exchange the received code with an access token and maybe a refresh token.

Trait Implementations§

source§

impl Debug for AuthorizationCodeGrant

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for AuthorizationCodeGrant

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more