Class AuthenticationApiClient
- Namespace
- Auth0.AuthenticationApi
- Assembly
- Auth0.AuthenticationApi.dll
Client for the Auth0 Authentication API.
public class AuthenticationApiClient : IAuthenticationApiClient, IDisposable
- Inheritance
-
AuthenticationApiClient
- Implements
- Inherited Members
- Extension Methods
Remarks
Full documentation on the Auth0 Authentication API is available at https://auth0.com/docs/api/authentication
Constructors
AuthenticationApiClient(string, IAuthenticationConnection)
Initializes a new instance of the AuthenticationApiClient class.
public AuthenticationApiClient(string domain, IAuthenticationConnection connection = null)
Parameters
domainstringYour Auth0 domain name, e.g. tenant.auth0.com.
connectionIAuthenticationConnectionOptional IAuthenticationConnection used to influence connection behavior. Defaults to a freshly created HttpClientAuthenticationConnection that uses a single HttpClient.
Remarks
To use a custom HttpClient or HttpMessageHandler create a HttpClientAuthenticationConnection passing that into the constructor. e.g.
var client = new AuthenticationApiClient(domain, new HttpClientAuthenticationConnection(myHttpClient)); or
var client = new AuthenticationApiClient(domain, new HttpClientAuthenticationConnection(myHttpMessageHandler)); or
AuthenticationApiClient(Uri, IAuthenticationConnection)
Initializes a new instance of the AuthenticationApiClient class.
public AuthenticationApiClient(Uri baseUri, IAuthenticationConnection connection = null)
Parameters
baseUriUriYour Auth0 domain URI, e.g. https://tenant.auth0.com
connectionIAuthenticationConnectionOptional IAuthenticationConnection used to influence connection behavior. Defaults to a freshly created HttpClientAuthenticationConnection that uses a single HttpClient.
Remarks
To use a custom HttpClient or HttpMessageHandler create a HttpClientAuthenticationConnection passing that into the constructor. e.g.
var client = new AuthenticationApiClient(baseUri, new HttpClientAuthenticationConnection(myHttpClient)); or
var client = new AuthenticationApiClient(baseUri, new HttpClientAuthenticationConnection(myHttpMessageHandler)); or
Fields
connection
protected readonly IAuthenticationConnection connection
Field Value
Properties
BaseUri
Base URI that will be used for all the requests.
public Uri BaseUri { get; }
Property Value
Methods
ChangePasswordAsync(ChangePasswordRequest, CancellationToken)
Requests a password change email for a given email address and connection.
public Task<string> ChangePasswordAsync(ChangePasswordRequest request, CancellationToken cancellationToken = default)
Parameters
requestChangePasswordRequestChangePasswordRequest specifying the user, connection and optional client details.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<string>
Task representing the async operation containing either the JSON error response or the plain text success message response.
Dispose()
Disposes of any owned disposable resources such as a IAuthenticationConnection.
public void Dispose()
Dispose(bool)
Disposes of any owned disposable resources such as a IAuthenticationConnection.
protected virtual void Dispose(bool disposing)
Parameters
GetImpersonationUrlAsync(ImpersonationRequest, CancellationToken)
Obtains a one-time link that can be used to log in as a specific user.
public Task<Uri> GetImpersonationUrlAsync(ImpersonationRequest request, CancellationToken cancellationToken = default)
Parameters
requestImpersonationRequestThe ImpersonationRequest containing the details of the user to impersonate.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
Remarks
This feature has been deprecated and will be removed from Auth0 and this library in a future release.
GetTokenAsync(AuthorizationCodePkceTokenRequest, CancellationToken)
Exchanges an Authorization Code using PKCE for an Access Token.
public Task<AccessTokenResponse> GetTokenAsync(AuthorizationCodePkceTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestAuthorizationCodePkceTokenRequestAuthorizationCodePkceTokenRequest containing Authorization Code and PKCE details.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(AuthorizationCodeTokenRequest, CancellationToken)
Exchanges an Authorization Code for an Access Token.
public Task<AccessTokenResponse> GetTokenAsync(AuthorizationCodeTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestAuthorizationCodeTokenRequestAuthorizationCodeTokenRequest containing Authorization Code details.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(ClientCredentialsTokenRequest, CancellationToken)
Requests an Access Token using the Client Credentials Grant flow.
public Task<AccessTokenResponse> GetTokenAsync(ClientCredentialsTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestClientCredentialsTokenRequestClientCredentialsTokenRequest containing client and audience details of the request.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(DeviceCodeTokenRequest, CancellationToken)
Requests an Access Token using the Device Authorization flow
public Task<AccessTokenResponse> GetTokenAsync(DeviceCodeTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestDeviceCodeTokenRequestDeviceCodeTokenRequest containing request details to exchange a device code.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
Remarks
This must be polled while the user is completing their part of the flow at an interval no more frequent than that returned by StartDeviceFlowAsync(DeviceCodeRequest, CancellationToken).
GetTokenAsync(PasswordlessEmailTokenRequest, CancellationToken)
Requests an Access Token using the Passwordless flow through email.
public Task<AccessTokenResponse> GetTokenAsync(PasswordlessEmailTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestPasswordlessEmailTokenRequestPasswordlessEmailTokenRequest containing request details to exchange a one time password received through email.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(PasswordlessSmsTokenRequest, CancellationToken)
Requests an Access Token using the Passwordless flow through SMS.
public Task<AccessTokenResponse> GetTokenAsync(PasswordlessSmsTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestPasswordlessSmsTokenRequestPasswordlessSmsTokenRequest containing request details to exchange a one time password received through SMS.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(RefreshTokenRequest, CancellationToken)
Refreshes all tokens by way of the the Refresh Token obtained during authorization.
public Task<AccessTokenResponse> GetTokenAsync(RefreshTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestRefreshTokenRequestRefreshTokenRequest containing Refresh Token and associated parameters.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
GetTokenAsync(ResourceOwnerTokenRequest, CancellationToken)
Performs authentication by providing user-supplied information in a ResourceOwnerTokenRequest.
public Task<AccessTokenResponse> GetTokenAsync(ResourceOwnerTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestResourceOwnerTokenRequestResourceOwnerTokenRequest containing information regarding the username, password etc.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<AccessTokenResponse>
Task representing the async operation containing a AccessTokenResponse with the requested tokens.
Remarks
The grant_type parameter required by the /oauth/token endpoint will automatically be inferred from the request parameter. If no Realm was specified,
then the grant_type will be set to "password". If a Realm was specified, then the grant_type will be set to "http://auth0.com/oauth/grant-type/password-realm"
GetUserInfoAsync(string, CancellationToken)
Returns user information based on the access token that was obtained during login.
public Task<UserInfo> GetUserInfoAsync(string accessToken, CancellationToken cancellationToken = default)
Parameters
accessTokenstringAccess token used to obtain the user information.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
Remarks
Information included in the response depends on the scopes initially granted.
PushedAuthorizationRequestAsync(PushedAuthorizationRequest, CancellationToken)
Starts a new Pushed Authorization Request flow.
public Task<PushedAuthorizationRequestResponse> PushedAuthorizationRequestAsync(PushedAuthorizationRequest request, CancellationToken cancellationToken = default)
Parameters
requestPushedAuthorizationRequestPushedAuthorizationRequest containing information to start the Pushed Authorization Request.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<PushedAuthorizationRequestResponse>
Task representing the async operation containing a PushedAuthorizationRequestResponse with the details of the response.
RevokeRefreshTokenAsync(RevokeRefreshTokenRequest, CancellationToken)
Revokes refresh token provided in request.
public Task RevokeRefreshTokenAsync(RevokeRefreshTokenRequest request, CancellationToken cancellationToken = default)
Parameters
requestRevokeRefreshTokenRequestRevokeRefreshTokenRequest containing Refresh Token and associated parameters.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
SignupUserAsync(SignupUserRequest, CancellationToken)
Creates a new user given the user details specified.
public Task<SignupUserResponse> SignupUserAsync(SignupUserRequest request, CancellationToken cancellationToken = default)
Parameters
requestSignupUserRequestSignupUserRequest containing information of the user to sign up.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<SignupUserResponse>
Task representing the async operation containing a SignupUserResponse with the information of the signed up user.
StartDeviceFlowAsync(DeviceCodeRequest, CancellationToken)
Starts a new Device Authorization flow
public Task<DeviceCodeResponse> StartDeviceFlowAsync(DeviceCodeRequest request, CancellationToken cancellationToken = default)
Parameters
requestDeviceCodeRequestDeviceCodeRequest containing client, scope and audience
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<DeviceCodeResponse>
Task representing the async operation containing a DeviceCodeResponse with the details of the request.
StartPasswordlessEmailFlowAsync(PasswordlessEmailRequest, CancellationToken)
Starts a new Passwordless email flow.
public Task<PasswordlessEmailResponse> StartPasswordlessEmailFlowAsync(PasswordlessEmailRequest request, CancellationToken cancellationToken = default)
Parameters
requestPasswordlessEmailRequestPasswordlessEmailRequest containing details about the Passwordless email flow to start.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<PasswordlessEmailResponse>
Task representing the async operation containing a PasswordlessEmailResponse with the information of the signed up user.
StartPasswordlessSmsFlowAsync(PasswordlessSmsRequest, CancellationToken)
Starts a new Passwordless SMS flow.
public Task<PasswordlessSmsResponse> StartPasswordlessSmsFlowAsync(PasswordlessSmsRequest request, CancellationToken cancellationToken = default)
Parameters
requestPasswordlessSmsRequestPasswordlessSmsRequest containing details about the Passwordless SMS flow to start.
cancellationTokenCancellationTokenThe cancellation token to cancel operation.
Returns
- Task<PasswordlessSmsResponse>
Task representing the async operation containing a PasswordlessSmsResponse with the details of the request.