pub struct AuthenticatorBuilder<C, F> { /* private fields */ }
Expand description

Configure an Authenticator using the builder pattern.

Implementations§

source§

impl<C, F> AuthenticatorBuilder<C, F>

Methods available when building any Authenticator.
    let authenticator = yup_oauth2::DeviceFlowAuthenticator::builder(app_secret)
        .hyper_client(custom_hyper_client)
        .persist_tokens_to_disk("/tmp/tokenfile.json")
        .build()
        .await
        .expect("failed to create authenticator");
source

pub fn with_storage(self, storage: Box<dyn TokenStorage>) -> Self

Use the provided token storage mechanism

source

pub fn hyper_client<NewC>( self, hyper_client: Client<NewC> ) -> AuthenticatorBuilder<Client<NewC>, F>

Use the provided hyper client.

source

pub fn persist_tokens_to_disk<P: Into<PathBuf>>( self, path: P ) -> AuthenticatorBuilder<C, F>

Persist tokens to disk in the provided filename.

source§

impl<C> AuthenticatorBuilder<C, DeviceFlow>

Methods available when building a device flow Authenticator.
    let authenticator = yup_oauth2::DeviceFlowAuthenticator::builder(app_secret)
        .device_code_url("foo")
        .flow_delegate(Box::new(custom_flow_delegate))
        .grant_type("foo")
        .build()
        .await
        .expect("failed to create authenticator");
source

pub fn device_code_url(self, url: impl Into<Cow<'static, str>>) -> Self

Use the provided device code url.

source

pub fn flow_delegate(self, flow_delegate: Box<dyn DeviceFlowDelegate>) -> Self

Use the provided DeviceFlowDelegate.

source

pub fn grant_type(self, grant_type: impl Into<Cow<'static, str>>) -> Self

Use the provided grant type.

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source§

impl<C> AuthenticatorBuilder<C, InstalledFlow>

Methods available when building an installed flow Authenticator.
    let authenticator = yup_oauth2::InstalledFlowAuthenticator::builder(
        app_secret,
        InstalledFlowReturnMethod::HTTPRedirect,
    )
    .flow_delegate(Box::new(custom_flow_delegate))
    .build()
    .await
    .expect("failed to create authenticator");
source

pub fn flow_delegate( self, flow_delegate: Box<dyn InstalledFlowDelegate> ) -> Self

Use the provided InstalledFlowDelegate.

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source§

impl<C> AuthenticatorBuilder<C, ServiceAccountFlowOpts>

Methods available when building a service account authenticator.
    let authenticator = yup_oauth2::ServiceAccountAuthenticator::builder(
        service_account_key,
    )
    .subject("mysubject")
    .build()
    .await
    .expect("failed to create authenticator");
source

pub fn subject(self, subject: impl Into<String>) -> Self

Use the provided subject.

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source§

impl<C> AuthenticatorBuilder<C, ApplicationDefaultCredentialsFlowOpts>

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source§

impl<C> AuthenticatorBuilder<C, AuthorizedUserFlow>

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source§

impl<C> AuthenticatorBuilder<C, ServiceAccountImpersonationFlow>

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

source

pub fn request_id_token(self) -> Self

Configure this authenticator to impersonate an ID token (rather an an access token, as is the default).

For more on impersonating ID tokens, see google’s docs.

source§

impl<C> AuthenticatorBuilder<C, AccessTokenFlow>

source

pub async fn build(self) -> Result<Authenticator<C::Connector>>where C: HyperClientBuilder,

Create the authenticator.

Auto Trait Implementations§

§

impl<C, F> !RefUnwindSafe for AuthenticatorBuilder<C, F>

§

impl<C, F> Send for AuthenticatorBuilder<C, F>where C: Send, F: Send,

§

impl<C, F> Sync for AuthenticatorBuilder<C, F>where C: Sync, F: Sync,

§

impl<C, F> Unpin for AuthenticatorBuilder<C, F>where C: Unpin, F: Unpin,

§

impl<C, F> !UnwindSafe for AuthenticatorBuilder<C, F>

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more