pub struct AuthorizationCodeGrant {
pub scopes: Vec<Scope>,
pub pkce: Option<(PkceCodeChallenge, PkceCodeVerifier)>,
}
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)>
Implementations§
Source§impl AuthorizationCodeGrant
impl AuthorizationCodeGrant
pub fn new() -> Self
pub fn with_scope<T>(self, scope: T) -> Selfwhere
T: ToString,
pub fn with_pkce(self) -> Self
Sourcepub fn get_redirect_url(&self, client: &Client) -> (Url, CsrfToken)
pub fn get_redirect_url(&self, client: &Client) -> (Url, CsrfToken)
Generate the redirect URL used to complete the OAuth 2.0 Authorization Code Grant flow.
Sourcepub async fn wait_for_redirection(
self,
client: &Client,
csrf_state: CsrfToken,
) -> Result<(String, Option<String>)>
pub async fn wait_for_redirection( self, client: &Client, 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
impl Debug for AuthorizationCodeGrant
Source§impl Default for AuthorizationCodeGrant
impl Default for AuthorizationCodeGrant
Source§fn default() -> AuthorizationCodeGrant
fn default() -> AuthorizationCodeGrant
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for AuthorizationCodeGrant
impl RefUnwindSafe for AuthorizationCodeGrant
impl Send for AuthorizationCodeGrant
impl Sync for AuthorizationCodeGrant
impl Unpin for AuthorizationCodeGrant
impl UnwindSafe for AuthorizationCodeGrant
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