[][src]Struct yup_oauth2::Authenticator

pub struct Authenticator<T: AuthFlow<C::Connector>, S: TokenStorage, AD: AuthenticatorDelegate, C: HyperClientBuilder> { /* fields omitted */ }

An authenticator can be used with InstalledFlow's or DeviceFlow's and will refresh tokens as they expire as well as optionally persist tokens to disk.

Methods

impl<T> Authenticator<T, MemoryStorage, DefaultAuthenticatorDelegate, DefaultHyperClient> where
    T: AuthFlow<<DefaultHyperClient as HyperClientBuilder>::Connector>, 
[src]

pub fn new(
    flow: T
) -> Authenticator<T, MemoryStorage, DefaultAuthenticatorDelegate, DefaultHyperClient>
[src]

Create a new authenticator with the provided flow. By default a new hyper::Client will be created the default authenticator delegate will be used, and tokens will not be persisted to disk. Accepted flow types are DeviceFlow and InstalledFlow.

Examples

use std::path::Path;
use yup_oauth2::{ApplicationSecret, Authenticator, DeviceFlow};
let creds = ApplicationSecret::default();
let auth = Authenticator::new(DeviceFlow::new(creds)).build().unwrap();

impl<T, S, AD, C> Authenticator<T, S, AD, C> where
    T: AuthFlow<C::Connector>,
    S: TokenStorage,
    AD: AuthenticatorDelegate,
    C: HyperClientBuilder, 
[src]

pub fn hyper_client<NewC>(
    self,
    hyper_client: Client<NewC>
) -> Authenticator<T, S, AD, Client<NewC>> where
    NewC: Connect,
    T: AuthFlow<NewC>, 
[src]

Use the provided hyper client.

pub fn persist_tokens_to_disk<P: AsRef<Path>>(
    self,
    path: P
) -> Authenticator<T, DiskTokenStorage, AD, C>
[src]

Persist tokens to disk in the provided filename.

pub fn delegate<NewAD: AuthenticatorDelegate>(
    self,
    delegate: NewAD
) -> Authenticator<T, S, NewAD, C>
[src]

Use the provided authenticator delegate.

pub fn build(self) -> Result<impl GetToken> where
    T::TokenGetter: 'static + GetToken + Send,
    S: 'static + Send,
    AD: 'static + Send,
    C::Connector: 'static + Clone + Send
[src]

Create the authenticator.

Auto Trait Implementations

impl<T, S, AD, C> Send for Authenticator<T, S, AD, C> where
    AD: Send,
    C: Send,
    S: Send,
    T: Send

impl<T, S, AD, C> Unpin for Authenticator<T, S, AD, C> where
    AD: Unpin,
    C: Unpin,
    S: Unpin,
    T: Unpin

impl<T, S, AD, C> Sync for Authenticator<T, S, AD, C> where
    AD: Sync,
    C: Sync,
    S: Sync,
    T: Sync

impl<T, S, AD, C> !UnwindSafe for Authenticator<T, S, AD, C>

impl<T, S, AD, C> !RefUnwindSafe for Authenticator<T, S, AD, C>

Blanket Implementations

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

impl<T> From<T> for 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> Erased for T