[][src]Struct yup_oauth2::Authenticator

pub struct Authenticator<D, S, C> { /* fields omitted */ }

A generalized authenticator which will keep tokens valid and store them.

It is the go-to helper to deal with any kind of supported authentication flow, which will be kept valid and usable.

Device Flow

This involves polling the authentication server in the given intervals until there is a definitive result.

These results will be passed the DeviceFlowHelperDelegate implementation to deal with

  • presenting the user code
  • inform the user about the progress or errors
  • abort the operation

Usage

Please have a look at the library's landing page.

Methods

impl<D, S, C> Authenticator<D, S, C> where
    D: AuthenticatorDelegate,
    S: TokenStorage,
    C: BorrowMut<Client>, 
[src]

pub fn new(
    secret: &ApplicationSecret,
    delegate: D,
    client: C,
    storage: S,
    flow_type: Option<FlowType>
) -> Authenticator<D, S, C>
[src]

Returns a new Authenticator instance

Arguments

  • secret - usually obtained from a client secret file produced by the [developer console][dev-con]
  • delegate - Used to further refine the flow of the authentication.
  • client - used for all authentication https requests
  • storage - used to cache authorization tokens tokens permanently. However, the implementation doesn't have any particular semantic requirement, which is why NullStorage and MemoryStorage can be used as well.
  • flow_type - the kind of authentication to use to obtain a token for the required scopes. If unset, it will be derived from the secret. [dev-con]: https://console.developers.google.com

Trait Implementations

impl<D, S, C> GetToken for Authenticator<D, S, C> where
    D: AuthenticatorDelegate,
    S: TokenStorage,
    C: BorrowMut<Client>, 
[src]

fn token<'b, I, T>(&mut self, scopes: I) -> Result<Token, Box<dyn Error>> where
    T: AsRef<str> + Ord + 'b,
    I: IntoIterator<Item = &'b T>, 
[src]

Blocks until a token was retrieved from storage, from the server, or until the delegate decided to abort the attempt, or the user decided not to authorize the application. In any failure case, the delegate will be provided with additional information, and the caller will be informed about storage related errors. Otherwise it is guaranteed to be valid for the given scopes.

Auto Trait Implementations

impl<D, S, C> Sync for Authenticator<D, S, C> where
    C: Sync,
    D: Sync,
    S: Sync

impl<D, S, C> Send for Authenticator<D, S, C> where
    C: Send,
    D: Send,
    S: Send

impl<D, S, C> Unpin for Authenticator<D, S, C> where
    C: Unpin,
    D: Unpin,
    S: Unpin

impl<D, S, C> RefUnwindSafe for Authenticator<D, S, C> where
    C: RefUnwindSafe,
    D: RefUnwindSafe,
    S: RefUnwindSafe

impl<D, S, C> UnwindSafe for Authenticator<D, S, C> where
    C: UnwindSafe,
    D: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.