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

The client used to make requests towards the Auth0 API.

Implementations§

source§

impl Auth0Client

source

pub fn new( client_id: &str, client_secret: &str, domain: &str, audience: &str ) -> Auth0Client

Creates a new client from given configuration.

source

pub fn jwks(&self) -> Option<&JWKS>

Get a reference to the stored JWKS

source

pub fn set_jwks(&mut self, jwks: JWKS)

Set the JWKS

source

pub fn grant_type(&mut self, grant_type: GrantType) -> &Auth0Client

Sets the grant type for the client.

source

pub async fn request<B, R, E>( &mut self, method: Method, path: &str, body: Option<B> ) -> Auth0Result<Option<R>>

Make a request towards the Auth0 API. It uses the audience field as the base URL.

If access token is expired, it will first try to get a new one.

§Parameters
  • method: The HTTP method to use.
  • path: The path to use for the request.
  • body: The body to send with the request.
§Example
client.request::<String, UserResponse, UserError>(reqwest::Method::GET, "/api/v2/users", None).await?;

Trait Implementations§

source§

impl Authenticatable for Auth0Client

source§

fn authenticate<'life0, 'async_trait>( &'life0 mut self ) -> Pin<Box<dyn Future<Output = Auth0Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Authenticates the client from its configuration. Read more
source§

fn authenticate_user<'life0, 'async_trait>( &'life0 mut self, username: String, password: String ) -> Pin<Box<dyn Future<Output = Auth0Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Authenticates the a user from its password. Read more
source§

fn authenticate_with_body<'life0, 'life1, 'async_trait>( &'life0 mut self, body: HashMap<&'life1 str, String> ) -> Pin<Box<dyn Future<Output = Auth0Result<AccessTokenResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Calls an authentication request with body
source§

fn access_token(&self) -> Option<String>

Returns the access token if autenticated or None if it is not.
source§

impl OperateUsers for Auth0Client

source§

fn get_user<'life0, 'life1, 'async_trait>( &'life0 mut self, user_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Auth0Result<UserResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets a user through the Auth0 users API. Read more
source§

fn get_user_by_email<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, email: &'life1 str, connection: &'life2 str ) -> Pin<Box<dyn Future<Output = Auth0Result<Option<UserResponse>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Gets a user through the Auth0 users API. Read more
source§

fn create_user<'life0, 'life1, 'async_trait>( &'life0 mut self, payload: &'life1 CreateUserPayload ) -> Pin<Box<dyn Future<Output = Auth0Result<UserResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Creates a user through the Auth0 users API. Read more
source§

fn update_user<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, user_id: &'life1 str, payload: &'life2 UpdateUserPayload ) -> Pin<Box<dyn Future<Output = Auth0Result<UserResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Updates a user through the Auth0 users API. Read more
source§

fn delete_user<'life0, 'life1, 'async_trait>( &'life0 mut self, user_id: &'life1 str ) -> Pin<Box<dyn Future<Output = Auth0Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a user through the Auth0 users API. Read more
source§

fn check_password<'life0, 'life1, 'async_trait>( &'life0 mut self, payload: &'life1 CheckPasswordPayload ) -> Pin<Box<dyn Future<Output = Auth0Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check a user’s password through the Auth0 users API. Read more

Auto Trait Implementations§

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