Type Alias AuthCodeClient

Source
pub type AuthCodeClient<A> = Client<A, AuthCodeFlow>;
Expand description

A client created using the Authorisation Code Flow.

Aliased Type§

pub struct AuthCodeClient<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 AuthCodeClient<Unauthenticated>

Source

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

Create a new client and generate an authorisation URL

You must redirect the user to the returned 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, AuthCodeFlow>>

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 AuthCodeClient<Token>

Source

pub async fn from_access_token( client_id: impl Into<String>, client_secret: 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).