Class UsersClient
- Namespace
- Auth0.ManagementApi
- Assembly
- Auth0.ManagementApi.dll
public class UsersClient : IUsersClient
- Inheritance
-
UsersClient
- Implements
- Inherited Members
- Extension Methods
Properties
AuthenticationMethods
public IAuthenticationMethodsClient AuthenticationMethods { get; }
Property Value
Authenticators
public IAuthenticatorsClient Authenticators { get; }
Property Value
ConnectedAccounts
public IConnectedAccountsClient ConnectedAccounts { get; }
Property Value
Enrollments
public IEnrollmentsClient Enrollments { get; }
Property Value
FederatedConnectionsTokensets
public IFederatedConnectionsTokensetsClient FederatedConnectionsTokensets { get; }
Property Value
Groups
public IGroupsClient Groups { get; }
Property Value
Identities
public IIdentitiesClient Identities { get; }
Property Value
Logs
public ILogsClient Logs { get; }
Property Value
Multifactor
public IMultifactorClient Multifactor { get; }
Property Value
Organizations
public IOrganizationsClient Organizations { get; }
Property Value
Permissions
public IPermissionsClient Permissions { get; }
Property Value
RefreshToken
public IRefreshTokenClient RefreshToken { get; }
Property Value
RiskAssessments
public IRiskAssessmentsClient RiskAssessments { get; }
Property Value
Roles
public IRolesClient Roles { get; }
Property Value
Sessions
public ISessionsClient Sessions { get; }
Property Value
Methods
CreateAsync(CreateUserRequestContent, RequestOptions?, CancellationToken)
Create a new user for a given database or passwordless connection.
Note: connection is required but other parameters such as email and password are dependent upon the type of connection.
public WithRawResponseTask<CreateUserResponseContent> CreateAsync(CreateUserRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
requestCreateUserRequestContentoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.CreateAsync(new CreateUserRequestContent { Connection = "connection" });
DeleteAsync(string, RequestOptions?, CancellationToken)
Delete a user by user ID. This action cannot be undone. For Auth0 Dashboard instructions, see Delete Users.
public Task DeleteAsync(string id, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
idstringoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.DeleteAsync("id");
GetAsync(string, GetUserRequestParameters, RequestOptions?, CancellationToken)
Retrieve user details. A list of fields to include or exclude may also be specified. For more information, see Retrieve Users with the Get Users Endpoint.
public WithRawResponseTask<GetUserResponseContent> GetAsync(string id, GetUserRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
idstringrequestGetUserRequestParametersoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.GetAsync(
"id",
new GetUserRequestParameters { Fields = "fields", IncludeFields = true }
);
ListAsync(ListUsersRequestParameters, RequestOptions?, CancellationToken)
Retrieve details of users. It is possible to:
- Specify a search criteria for users
- Sort the users to be returned
- Select the fields to be returned
- Specify the number of users to retrieve per page and the page index
The q query parameter can be used to get users that match the specified criteria using query string syntax.
Learn more about searching for users.
Read about best practices when working with the API endpoints for retrieving users.
Auth0 limits the number of users you can return. If you exceed this threshold, please redefine your search, use the export job, or the User Import / Export extension.
public Task<Pager<UserResponseSchema>> ListAsync(ListUsersRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
requestListUsersRequestParametersoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.ListAsync(
new ListUsersRequestParameters
{
Page = 1,
PerPage = 1,
IncludeTotals = true,
Sort = "sort",
Connection = "connection",
Fields = "fields",
IncludeFields = true,
Q = "q",
SearchEngine = SearchEngineVersionsEnum.V1,
PrimaryOrder = true,
}
);
ListUsersByEmailAsync(ListUsersByEmailRequestParameters, RequestOptions?, CancellationToken)
Find users by email. If Auth0 is the identity provider (idP), the email address associated with a user is saved in lower case, regardless of how you initially provided it.
For example, if you register a user as JohnSmith@example.com, Auth0 saves the user's email as johnsmith@example.com.
Therefore, when using this endpoint, make sure that you are searching for users via email addresses using the correct case.
public WithRawResponseTask<IEnumerable<UserResponseSchema>> ListUsersByEmailAsync(ListUsersByEmailRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
requestListUsersByEmailRequestParametersoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.ListUsersByEmailAsync(
new ListUsersByEmailRequestParameters
{
Fields = "fields",
IncludeFields = true,
Email = "email",
}
);
RegenerateRecoveryCodeAsync(string, RequestOptions?, CancellationToken)
Remove an existing multi-factor authentication (MFA) recovery code and generate a new one. If a user cannot access the original device or account used for MFA enrollment, they can use a recovery code to authenticate.
public WithRawResponseTask<RegenerateUsersRecoveryCodeResponseContent> RegenerateRecoveryCodeAsync(string id, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
idstringoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.RegenerateRecoveryCodeAsync("id");
RevokeAccessAsync(string, RevokeUserAccessRequestContent, RequestOptions?, CancellationToken)
Revokes selected resources related to a user (sessions, refresh tokens, ...).
public Task RevokeAccessAsync(string id, RevokeUserAccessRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
idstringrequestRevokeUserAccessRequestContentoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.RevokeAccessAsync("id", new RevokeUserAccessRequestContent());
UpdateAsync(string, UpdateUserRequestContent, RequestOptions?, CancellationToken)
Update a user.
These are the attributes that can be updated at the root level:
<ul><li>app_metadata</li><li>blocked</li><li>email</li><li>email_verified</li><li>family_name</li><li>given_name</li><li>name</li><li>nickname</li><li>password</li><li>phone_number</li><li>phone_verified</li><li>picture</li><li>username</li><li>user_metadata</li><li>verify_email</li></ul>
Some considerations:
<ul><li>The properties of the new object will replace the old ones.</li><li>The metadata fields are an exception to this rule (<code>user_metadata</code> and <code>app_metadata</code>). These properties are merged instead of being replaced but be careful, the merge only occurs on the first level.</li><li>If you are updating <code>email</code>, <code>email_verified</code>, <code>phone_number</code>, <code>phone_verified</code>, <code>username</code> or <code>password</code> of a secondary identity, you need to specify the <code>connection</code> property too.</li><li>If you are updating <code>email</code> or <code>phone_number</code> you can specify, optionally, the <code>client_id</code> property.</li><li>Updating <code>email_verified</code> is not supported for enterprise and passwordless sms connections.</li><li>Updating the <code>blocked</code> to <code>false</code> does not affect the user's blocked state from an excessive amount of incorrectly provided credentials. Use the "Unblock a user" endpoint from the "User Blocks" API to change the user's state.</li><li>Supported attributes can be unset by supplying <code>null</code> as the value.</li></ul>
<p>Updating a field (non-metadata property)</p>
To mark the email address of a user as verified, the body to send should be:
<pre><code class="lang-csharp">{ "email_verified": true }</code></pre>
<p>Updating a user metadata root property</p>
Let's assume that our test user has the following user_metadata:
<pre><code class="lang-csharp">{ "user_metadata" : { "profileCode": 1479 } }</code></pre>
To add the field <code>addresses</code> the body to send should be:
<pre><code class="lang-csharp">{ "user_metadata" : { "addresses": {"work_address": "100 Industrial Way"} }}</code></pre>
The modified object ends up with the following <code>user_metadata</code> property:
{
"user_metadata": {
"profileCode": 1479,
"addresses": { "work_address": "100 Industrial Way" }
}
}
<p>Updating an inner user metadata property</p>
If there's existing user metadata to which we want to add "home_address": "742 Evergreen Terrace" (using the addresses property) we should send the whole addresses object. Since this is a first-level object, the object will be merged in, but its own properties will not be. The body to send should be:
<pre><code class="lang-csharp">{
"user_metadata": {
"addresses": {
"work_address": "100 Industrial Way",
"home_address": "742 Evergreen Terrace"
}
}
}</code></pre>
The modified object ends up with the following <code>user_metadata</code> property:
<pre><code class="lang-csharp">{
"user_metadata": {
"profileCode": 1479,
"addresses": {
"work_address": "100 Industrial Way",
"home_address": "742 Evergreen Terrace"
}
}
}</code></pre>
public WithRawResponseTask<UpdateUserResponseContent> UpdateAsync(string id, UpdateUserRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default)
Parameters
idstringrequestUpdateUserRequestContentoptionsRequestOptionscancellationTokenCancellationToken
Returns
Examples
await client.Users.UpdateAsync("id", new UpdateUserRequestContent());