AuthCodePkceClient

Type Alias AuthCodePkceClient 

Source
pub type AuthCodePkceClient<A> = Client<A, AuthCodePkceFlow>;
Expand description

A client created using the Authorisation Code with PKCE Flow.

Aliased Type§

pub struct AuthCodePkceClient<A> {
    pub auto_refresh: bool,
    /* private fields */
}

Fields§

§auto_refresh: bool

Dictates whether or not the client will request a new token when the current one is about the expire.

It will check if the token has expired in every request.

Implementations§

Source§

impl AuthCodePkceClient<Unauthenticated>

Source

pub fn new<T, S>( client_id: T, scopes: S, redirect_uri: RedirectUrl, auto_refresh: bool, ) -> (Self, Url)
where T: Into<String>, S: Into<Scopes>,

Create a new client and generate an authorisation URL

You must redirect the user to the received URL, which in turn redirects them to the redirect URI you provided, along with a code and state parameter in the URl.

They are required for the next step in the auth process.

Source

pub async fn authenticate( self, auth_code: impl Into<String>, csrf_state: impl AsRef<str>, ) -> Result<Client<Token, AuthCodePkceFlow>>

This will exchange the auth_code for a token which will allow the client to make requests.

csrf_state is used for CSRF protection.

Source§

impl AuthCodePkceClient<Token>

Source

pub async fn from_access_token( client_id: impl Into<String>, auto_refresh: bool, token: Token, ) -> Result<Self>

Create a new authenticated client from an access token. This client will be able to access user data.

This method will fail if the access token is invalid (a request will be sent to check the token).