Table of Contents

Class UsersClient

Namespace
Auth0.ManagementApi.Clients
Assembly
Auth0.ManagementApi.dll

Contains methods to access the /users endpoints.

public class UsersClient : BaseClient, IUsersClient
Inheritance
UsersClient
Implements
Inherited Members

Constructors

UsersClient(IManagementConnection, Uri, IDictionary<string, string>)

Initializes a new instance of UsersClient.

public UsersClient(IManagementConnection connection, Uri baseUri, IDictionary<string, string> defaultHeaders)

Parameters

connection IManagementConnection

IManagementConnection used to make all API calls.

baseUri Uri

Uri of the endpoint to use in making API calls.

defaultHeaders IDictionary<string, string>

Dictionary containing default headers included with every request this client makes.

Methods

AssignPermissionsAsync(string, AssignPermissionsRequest, CancellationToken)

Assign permissions to a user.

public Task AssignPermissionsAsync(string id, AssignPermissionsRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the user to assign permissions to.

request AssignPermissionsRequest

A AssignPermissionsRequest containing the permission identifiers to assign to the user.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous assignment operation.

AssignRolesAsync(string, AssignRolesRequest, CancellationToken)

Assigns Roles to a user.

public Task AssignRolesAsync(string id, AssignRolesRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the user to assign roles to.

request AssignRolesRequest

A AssignRolesRequest containing the role IDs to assign to the user.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous assign operation.

CreateAsync(UserCreateRequest, CancellationToken)

Creates a new user.

public Task<User> CreateAsync(UserCreateRequest request, CancellationToken cancellationToken = default)

Parameters

request UserCreateRequest

The UserCreateRequest containing the properties of the user to create.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<User>

The newly created User.

CreateAuthenticationMethodAsync(string, AuthenticationMethodCreateRequest, CancellationToken)

Creates an authentication method for a given user.

public Task<AuthenticationMethod> CreateAuthenticationMethodAsync(string userId, AuthenticationMethodCreateRequest request, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to create the authentication method.

request AuthenticationMethodCreateRequest

The AuthenticationMethodCreateRequest containing the properties of the authentication method to create.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<AuthenticationMethod>

The newly created AuthenticationMethod.

Remarks

Authentication methods created via this endpoint will be auto confirmed and should already have verification completed.

DeleteAsync(string)

Deletes a user.

public Task DeleteAsync(string id)

Parameters

id string

The id of the user to delete.

Returns

Task

A Task that represents the asynchronous delete operation.

DeleteAuthenticationMethodAsync(string, string, CancellationToken)

Deletes an authentication method by id,.

public Task DeleteAuthenticationMethodAsync(string userId, string authenticationMethodId, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to delete the authentication methods.

authenticationMethodId string

The ID of the authentication method you want to delete.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous delete operation.

DeleteAuthenticationMethodsAsync(string, CancellationToken)

Deletes all authentication methods for the given user.

public Task DeleteAuthenticationMethodsAsync(string userId, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to update the authentication methods.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous delete operation.

DeleteMultifactorProviderAsync(string, string, CancellationToken)

Deletes a user's multifactor provider.

public Task DeleteMultifactorProviderAsync(string id, string provider, CancellationToken cancellationToken = default)

Parameters

id string

The id of the user who multi factor provider to delete.

provider string

The type of the multifactor provider. Supported values 'duo' or 'google-authenticator'.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous delete operation.

GenerateRecoveryCodeAsync(string, CancellationToken)

Generate new Guardian recovery code.

public Task<GenerateRecoveryCodeResponse> GenerateRecoveryCodeAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The user_id of the user which guardian code will be regenerated.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<GenerateRecoveryCodeResponse>

A Task representing the operation and potential return value.

GetAllAsync(GetUsersRequest, PaginationInfo, CancellationToken)

Lists or search for users based on criteria.

public Task<IPagedList<User>> GetAllAsync(GetUsersRequest request, PaginationInfo pagination = null, CancellationToken cancellationToken = default)

Parameters

request GetUsersRequest

Specifies criteria to use when querying users.

pagination PaginationInfo

Specifies pagination info to use when requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<User>>

An IPagedList<T> containing the list of users.

GetAllOrganizationsAsync(string, PaginationInfo, CancellationToken)

Lists organizations for a user.

public Task<IPagedList<Organization>> GetAllOrganizationsAsync(string userId, PaginationInfo pagination, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to retrieve the organizations.

pagination PaginationInfo

Specifies pagination info to use when requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<Organization>>

An IPagedList<T> containing the list of organizations.

GetAsync(string, string, bool, CancellationToken)

Gets a user.

public Task<User> GetAsync(string id, string fields = null, bool includeFields = true, CancellationToken cancellationToken = default)

Parameters

id string

The id of the user to retrieve.

fields string

A comma separated list of fields to include or exclude (depending on includeFields) from the result, empty to retrieve all fields

includeFields bool

true if the fields specified are to be included in the result, false otherwise (defaults to true)

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<User>

The User that was requested.

GetAuthenticationMethodAsync(string, string, CancellationToken)

Gets an authentication method for a given user.

public Task<AuthenticationMethod> GetAuthenticationMethodAsync(string userId, string authenticationMethodId, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to retrieve the authentication method.

authenticationMethodId string

The ID of the authentication method you want to retrieve.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<AuthenticationMethod>

The AuthenticationMethod that was requested.

GetAuthenticationMethodsAsync(string, PaginationInfo, CancellationToken)

Gets a list of authentication methods.

public Task<IPagedList<AuthenticationMethod>> GetAuthenticationMethodsAsync(string userId, PaginationInfo pagination = null, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to retrieve the authentication methods.

pagination PaginationInfo

Specifies pagination info to use when requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<AuthenticationMethod>>

An IPagedList<T> containing the list of authentication methods.

GetEnrollmentsAsync(string, CancellationToken)

Get a list of Guardian enrollments.

public Task<IList<EnrollmentsResponse>> GetEnrollmentsAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The user_id of the user to retrieve.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<EnrollmentsResponse>>

A Task representing the operation and potential return value.

GetLogsAsync(GetUserLogsRequest, PaginationInfo, CancellationToken)

Retrieve every log event for a specific user.

public Task<IPagedList<LogEntry>> GetLogsAsync(GetUserLogsRequest request, PaginationInfo pagination = null, CancellationToken cancellationToken = default)

Parameters

request GetUserLogsRequest

Specifies criteria to use when querying logs for a user.

pagination PaginationInfo

Specifies pagination info to use when requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<LogEntry>>

An IPagedList<T> containing the log entries for the user.

GetPermissionsAsync(string, PaginationInfo, CancellationToken)

Get the permissions assigned to the user.

public Task<IPagedList<UserPermission>> GetPermissionsAsync(string id, PaginationInfo pagination = null, CancellationToken cancellationToken = default)

Parameters

id string

The id of the user to obtain the permissions for.

pagination PaginationInfo

Specifies PaginationInfo to use in requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<UserPermission>>

An IPagedList<T> containing the assigned permissions for this user.

GetRolesAsync(string, PaginationInfo, CancellationToken)

Retrieve assigned roles for a specific user.

public Task<IPagedList<Role>> GetRolesAsync(string userId, PaginationInfo pagination = null, CancellationToken cancellationToken = default)

Parameters

userId string

The user id of the roles to retrieve.

pagination PaginationInfo

Specifies pagination info to use when requesting paged results.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IPagedList<Role>>

An IPagedList<T> containing the roles for the user.

GetUsersByEmailAsync(string, string, bool?, CancellationToken)

Gets all users by email address.

public Task<IList<User>> GetUsersByEmailAsync(string email, string fields = null, bool? includeFields = null, CancellationToken cancellationToken = default)

Parameters

email string

The email address to search for.

fields string

A comma separated list of fields to include or exclude (depending on includeFields) from the result, null to retrieve all fields.

includeFields bool?

true if the fields specified are to be included in the result, false otherwise. Defaults to true.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<User>>

A IList<T> containing all users for this email address.

InvalidateRememberBrowserAsync(string, CancellationToken)

Invalidate all remembered browsers for MFA.

public Task InvalidateRememberBrowserAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The user_id of the user which will have its remembered browsers for MFA invalidated.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task representing the operation and potential return value.

LinkAccountAsync(string, UserAccountLinkRequest, CancellationToken)

Links a secondary account to a primary account.

public Task<IList<AccountLinkResponse>> LinkAccountAsync(string id, UserAccountLinkRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the primary account.

request UserAccountLinkRequest

The UserAccountLinkRequest containing details of the secondary account to link.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<AccountLinkResponse>>

A IList<T> containing details about this account link.

LinkAccountAsync(string, string, string, CancellationToken)

Links a secondary account to a primary account.

public Task<IList<AccountLinkResponse>> LinkAccountAsync(string id, string primaryJwtToken, string secondaryJwtToken, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the primary account.

primaryJwtToken string

The JWT of the primary account.

secondaryJwtToken string

The JWT for the secondary account you wish to link.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<AccountLinkResponse>>

A IList<T> containing details about this account link.

RemovePermissionsAsync(string, AssignPermissionsRequest, CancellationToken)

Removes permissions assigned to a user.

public Task RemovePermissionsAsync(string id, AssignPermissionsRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the user to remove permissions from.

request AssignPermissionsRequest

A AssignPermissionsRequest containing the permission identifiers to remove from the user.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous remove operation.

RemoveRolesAsync(string, AssignRolesRequest, CancellationToken)

Removes Roles from a user.

public Task RemoveRolesAsync(string id, AssignRolesRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The ID of the user to remove roles from.

request AssignRolesRequest

A AssignRolesRequest containing the role IDs to remove to the user.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task

A Task that represents the asynchronous remove operation.

UnlinkAccountAsync(string, string, string, CancellationToken)

Unlinks user accounts

public Task<IList<AccountLinkResponse>> UnlinkAccountAsync(string primaryUserId, string provider, string secondaryUserId, CancellationToken cancellationToken = default)

Parameters

primaryUserId string

The ID of the primary account.

provider string

The type of the identity provider.

secondaryUserId string

The ID for the secondary account.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<AccountLinkResponse>>

A IList<T> containing details about this account link.

UpdateAsync(string, UserUpdateRequest, CancellationToken)

Updates a user.

public Task<User> UpdateAsync(string id, UserUpdateRequest request, CancellationToken cancellationToken = default)

Parameters

id string

The id of the user to update.

request UserUpdateRequest

The UserUpdateRequest containing the information you wish to update.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<User>

The newly updated User.

UpdateAuthenticationMethodAsync(string, string, AuthenticationMethodUpdateRequest, CancellationToken)

Update an authentication methods.

public Task<AuthenticationMethod> UpdateAuthenticationMethodAsync(string userId, string authenticationMethodId, AuthenticationMethodUpdateRequest request, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to update the authentication methods

authenticationMethodId string

The ID of the authentication method you want to update.

request AuthenticationMethodUpdateRequest

The AuthenticationMethodUpdateRequest containing the properties of the authentication methods to update.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<AuthenticationMethod>

The updated AuthenticationMethod.

UpdateAuthenticationMethodsAsync(string, IList<AuthenticationMethodsUpdateRequest>, CancellationToken)

Updates all authentication methods by replacing them with the given ones.

public Task<IList<AuthenticationMethod>> UpdateAuthenticationMethodsAsync(string userId, IList<AuthenticationMethodsUpdateRequest> request, CancellationToken cancellationToken = default)

Parameters

userId string

The ID of the user for which you want to update the authentication methods.

request IList<AuthenticationMethodsUpdateRequest>

The AuthenticationMethodsUpdateRequest containing the properties of the authentication methods to update.

cancellationToken CancellationToken

The cancellation token to cancel operation.

Returns

Task<IList<AuthenticationMethod>>

The updated list of AuthenticationMethod.