Passer au contenu principal
POST
https://{tenantDomain}/api/v2
/
users
/
{id}
/
roles
Go
package example

import (
    client "github.com/auth0/go-auth0/management/client"
    option "github.com/auth0/go-auth0/management/option"
    context "context"
    users "github.com/auth0/go-auth0/management/users"
)

func do() () {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    client.Users.Roles.Assign(
        context.TODO(),
        "id",
        &users.AssignUserRolesRequestContent{
            Roles: []string{
                "roles",
            },
        },
    )
}

Autorisations

Authorization
string
header
requis

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Paramètres de chemin

id
string
requis

ID of the user to associate roles with.

Corps

roles
string[]
requis

List of roles IDs to associated with the user.

Minimum array length: 1
Minimum string length: 1

Réponse

Roles successfully associated with user.