Skip to main content

Auth

Struct Auth 

Source
pub struct Auth { /* private fields */ }
Expand description

The configured authentication flow. Build one with Auth::developer_token, Auth::client_credentials, or Auth::oauth, then pass it to Client::new.

Implementations§

Source§

impl Auth

Source

pub fn developer_token(token: impl Into<String>) -> Auth

The simplest flow: a fixed access token from the Box developer console.

Source

pub fn client_credentials(config: CcgConfig) -> Auth

Client Credentials Grant: server-to-server auth with no signing key. Set exactly one subject on the config — enterprise_id for the service account, or user_id to act as a managed user.

Source

pub fn jwt(config: JwtConfig) -> Result<Auth, Error>

JWT server auth: sign a short-lived RSA assertion (from the app’s box_config.json) and exchange it for an access token. Set exactly one subject on the config — enterprise_id or user_id.

Fallible: the RSA private key is parsed (and if needed decrypted) up front, so a bad key fails here rather than on the first request.

Source

pub fn oauth(config: OAuthConfig, refresh_token: impl Into<String>) -> Auth

Resume the OAuth 2.0 authorization-code flow from a previously stored refresh token, exchanging it for access tokens as needed. Box rotates the refresh token on each exchange, so the newest one is retained.

The rotated token is held in memory only; use Auth::oauth_with_store to persist each rotation durably across restarts.

Source

pub fn oauth_with_store( config: OAuthConfig, refresh_token: impl Into<String>, store: Arc<dyn RefreshTokenStore>, ) -> Auth

Like Auth::oauth, but persists each rotated refresh token through a RefreshTokenStore before returning — so an app restart reloads the live token instead of a refresh token Box has already invalidated.

Source

pub fn custom(source: Arc<dyn TokenSource>) -> Auth

Build an Auth from a custom TokenSource — for callers that need to own token acquisition and refresh outside the built-in flows (e.g. an engine-owned token cache with proactive refresh and per-identity fan-out) instead of one of the flows above.

Auto Trait Implementations§

§

impl !Freeze for Auth

§

impl !RefUnwindSafe for Auth

§

impl !UnwindSafe for Auth

§

impl Send for Auth

§

impl Sync for Auth

§

impl Unpin for Auth

§

impl UnsafeUnpin for Auth

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

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 T
where 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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