Table of Contents

Class RolesClient

Namespace
Auth0.ManagementApi.Users
Assembly
Auth0.ManagementApi.dll
public class RolesClient : IRolesClient
Inheritance
RolesClient
Implements
Inherited Members
Extension Methods

Methods

AssignAsync(string, AssignUserRolesRequestContent, RequestOptions?, CancellationToken)

Assign one or more existing user roles to a user. For more information, review Role-Based Access Control.

Note: New roles cannot be created through this action. Additionally, this action is used to assign roles to a user in the context of your whole tenant. To assign roles in the context of a specific Organization, use the following endpoint: Assign user roles to an Organization member.

public Task AssignAsync(string id, AssignUserRolesRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

id string
request AssignUserRolesRequestContent
options RequestOptions
cancellationToken CancellationToken

Returns

Task

Examples

await client.Users.Roles.AssignAsync(
    "id",
    new AssignUserRolesRequestContent { Roles = new List<string>() { "roles" } }
);

DeleteAsync(string, DeleteUserRolesRequestContent, RequestOptions?, CancellationToken)

Remove one or more specified user roles assigned to a user.

Note: This action removes a role from a user in the context of your whole tenant. If you want to unassign a role from a user in the context of a specific Organization, use the following endpoint: Delete user roles from an Organization member.

public Task DeleteAsync(string id, DeleteUserRolesRequestContent request, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

id string
request DeleteUserRolesRequestContent
options RequestOptions
cancellationToken CancellationToken

Returns

Task

Examples

await client.Users.Roles.DeleteAsync(
    "id",
    new DeleteUserRolesRequestContent { Roles = new List<string>() { "roles" } }
);

ListAsync(string, ListUserRolesRequestParameters, RequestOptions?, CancellationToken)

Retrieve detailed list of all user roles currently assigned to a user.

Note: This action retrieves all roles assigned to a user in the context of your whole tenant. To retrieve Organization-specific roles, use the following endpoint: Get user roles assigned to an Organization member.

public Task<Pager<Role>> ListAsync(string id, ListUserRolesRequestParameters request, RequestOptions? options = null, CancellationToken cancellationToken = default)

Parameters

id string
request ListUserRolesRequestParameters
options RequestOptions
cancellationToken CancellationToken

Returns

Task<Pager<Role>>

Examples

await client.Users.Roles.ListAsync(
    "id",
    new ListUserRolesRequestParameters
    {
        PerPage = 1,
        Page = 1,
        IncludeTotals = true,
    }
);