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
IManagementConnectionIManagementConnection used to make all API calls.
baseUri
UriUri 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
stringThe ID of the user to assign permissions to.
request
AssignPermissionsRequestA AssignPermissionsRequest containing the permission identifiers to assign to the user.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
AssignRolesAsync(string, AssignRolesRequest, CancellationToken)
Assigns Roles to a user.
public Task AssignRolesAsync(string id, AssignRolesRequest request, CancellationToken cancellationToken = default)
Parameters
id
stringThe ID of the user to assign roles to.
request
AssignRolesRequestA AssignRolesRequest containing the role IDs to assign to the user.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
CreateAsync(UserCreateRequest, CancellationToken)
Creates a new user.
public Task<User> CreateAsync(UserCreateRequest request, CancellationToken cancellationToken = default)
Parameters
request
UserCreateRequestThe UserCreateRequest containing the properties of the user to create.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
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
stringThe ID of the user for which you want to create the authentication method.
request
AuthenticationMethodCreateRequestThe AuthenticationMethodCreateRequest containing the properties of the authentication method to create.
cancellationToken
CancellationTokenThe 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
stringThe id of the user to delete.
Returns
DeleteAuthenticationMethodAsync(string, string, CancellationToken)
Deletes an authentication method by id,.
public Task DeleteAuthenticationMethodAsync(string userId, string authenticationMethodId, CancellationToken cancellationToken = default)
Parameters
userId
stringThe ID of the user for which you want to delete the authentication methods.
authenticationMethodId
stringThe ID of the authentication method you want to delete.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
DeleteAuthenticationMethodsAsync(string, CancellationToken)
Deletes all authentication methods for the given user.
public Task DeleteAuthenticationMethodsAsync(string userId, CancellationToken cancellationToken = default)
Parameters
userId
stringThe ID of the user for which you want to update the authentication methods.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
DeleteMultifactorProviderAsync(string, string, CancellationToken)
Deletes a user's multifactor provider.
public Task DeleteMultifactorProviderAsync(string id, string provider, CancellationToken cancellationToken = default)
Parameters
id
stringThe id of the user who multi factor provider to delete.
provider
stringThe type of the multifactor provider. Supported values 'duo' or 'google-authenticator'.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
GenerateRecoveryCodeAsync(string, CancellationToken)
Generate new Guardian recovery code.
public Task<GenerateRecoveryCodeResponse> GenerateRecoveryCodeAsync(string id, CancellationToken cancellationToken = default)
Parameters
id
stringThe user_id of the user which guardian code will be regenerated.
cancellationToken
CancellationTokenThe 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
GetUsersRequestSpecifies criteria to use when querying users.
pagination
PaginationInfoSpecifies pagination info to use when requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe ID of the user for which you want to retrieve the organizations.
pagination
PaginationInfoSpecifies pagination info to use when requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe id of the user to retrieve.
fields
stringA comma separated list of fields to include or exclude (depending on includeFields) from the result, empty to retrieve all fields
includeFields
booltrue if the fields specified are to be included in the result, false otherwise (defaults to true)
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
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
stringThe ID of the user for which you want to retrieve the authentication method.
authenticationMethodId
stringThe ID of the authentication method you want to retrieve.
cancellationToken
CancellationTokenThe 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
stringThe ID of the user for which you want to retrieve the authentication methods.
pagination
PaginationInfoSpecifies pagination info to use when requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe user_id of the user to retrieve.
cancellationToken
CancellationTokenThe 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
GetUserLogsRequestSpecifies criteria to use when querying logs for a user.
pagination
PaginationInfoSpecifies pagination info to use when requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe id of the user to obtain the permissions for.
pagination
PaginationInfoSpecifies PaginationInfo to use in requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe user id of the roles to retrieve.
pagination
PaginationInfoSpecifies pagination info to use when requesting paged results.
cancellationToken
CancellationTokenThe 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
stringThe email address to search for.
fields
stringA 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
CancellationTokenThe cancellation token to cancel operation.
Returns
InvalidateRememberBrowserAsync(string, CancellationToken)
Invalidate all remembered browsers for MFA.
public Task InvalidateRememberBrowserAsync(string id, CancellationToken cancellationToken = default)
Parameters
id
stringThe user_id of the user which will have its remembered browsers for MFA invalidated.
cancellationToken
CancellationTokenThe 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
stringThe ID of the primary account.
request
UserAccountLinkRequestThe UserAccountLinkRequest containing details of the secondary account to link.
cancellationToken
CancellationTokenThe 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
stringThe ID of the primary account.
primaryJwtToken
stringThe JWT of the primary account.
secondaryJwtToken
stringThe JWT for the secondary account you wish to link.
cancellationToken
CancellationTokenThe 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
stringThe ID of the user to remove permissions from.
request
AssignPermissionsRequestA AssignPermissionsRequest containing the permission identifiers to remove from the user.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
RemoveRolesAsync(string, AssignRolesRequest, CancellationToken)
Removes Roles from a user.
public Task RemoveRolesAsync(string id, AssignRolesRequest request, CancellationToken cancellationToken = default)
Parameters
id
stringThe ID of the user to remove roles from.
request
AssignRolesRequestA AssignRolesRequest containing the role IDs to remove to the user.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
UnlinkAccountAsync(string, string, string, CancellationToken)
Unlinks user accounts
public Task<IList<AccountLinkResponse>> UnlinkAccountAsync(string primaryUserId, string provider, string secondaryUserId, CancellationToken cancellationToken = default)
Parameters
primaryUserId
stringThe ID of the primary account.
provider
stringThe type of the identity provider.
secondaryUserId
stringThe ID for the secondary account.
cancellationToken
CancellationTokenThe 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
stringThe id of the user to update.
request
UserUpdateRequestThe UserUpdateRequest containing the information you wish to update.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
UpdateAuthenticationMethodAsync(string, string, AuthenticationMethodUpdateRequest, CancellationToken)
Update an authentication methods.
public Task<AuthenticationMethod> UpdateAuthenticationMethodAsync(string userId, string authenticationMethodId, AuthenticationMethodUpdateRequest request, CancellationToken cancellationToken = default)
Parameters
userId
stringThe ID of the user for which you want to update the authentication methods
authenticationMethodId
stringThe ID of the authentication method you want to update.
request
AuthenticationMethodUpdateRequestThe AuthenticationMethodUpdateRequest containing the properties of the authentication methods to update.
cancellationToken
CancellationTokenThe 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
stringThe 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
CancellationTokenThe cancellation token to cancel operation.
Returns
- Task<IList<AuthenticationMethod>>
The updated list of AuthenticationMethod.