pub struct Authorization { /* private fields */ }
Expand description

Provides for continuing authorization of the app.

Implementations§

source§

impl Authorization

source

pub fn from_auth_code( client_id: String, flow_type: Oauth2Type, auth_code: String, redirect_uri: Option<String> ) -> Self

Create a new instance using the authorization code provided upon redirect back to your app (or via manual user entry if not using a redirect URI) after the user logs in.

Requires the client ID; the type of OAuth2 flow being used (including the client secret or the PKCE challenge); the authorization code; and the redirect URI used for the original authorization request, if any.

source

pub fn save(&self) -> Option<String>

Save the authorization state to a string which can be reloaded later.

Returns None if the state cannot be saved (e.g. authorization has not completed getting a token yet).

source

pub fn load(client_id: String, saved: &str) -> Option<Self>

Reload a saved authorization state produced by save.

Returns None if the string could not be recognized. In this case, you should start the authorization procedure from scratch.

Note that a loaded authorization state is not necessarily still valid and may produce Authentication errors. In such a case you should also start the authorization procedure from scratch.

source

pub fn from_refresh_token(client_id: String, refresh_token: String) -> Self

Recreate the authorization from an authorization code and refresh token.

source

pub fn from_access_token(access_token: String) -> Self

Recreate the authorization from a long-lived access token. This token cannot be refreshed; any call to obtain_access_token will simply return the given token.

source

pub fn obtain_access_token( &mut self, client: impl NoauthClient ) -> Result<String>

Obtain an access token. Use this to complete the authorization process, or to obtain an updated token when a short-lived access token has expired.

Trait Implementations§

source§

impl Clone for Authorization

source§

fn clone(&self) -> Authorization

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Authorization

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.