public function Roles::addUsers in Auth0 Single Sign On 8.2
Add one or more users to a role. Required scopes: "update:roles"
@link https://auth0.com/docs/api/management/v2#!/Roles/post_role_users
Parameters
string $role_id Role ID to add users.:
array $users Array of user IDs to add to the role.:
Return value
mixed
Throws
EmptyOrInvalidParameterException Thrown if the role_id parameter is empty or is not a string.
CoreException Thrown if the users parameter is empty.
\Exception Thrown by the HTTP client when there is a problem with the API call.
File
- vendor/
auth0/ auth0-php/ src/ API/ Management/ Roles.php, line 262
Class
- Roles
- Class Roles. Handles requests to the Roles endpoint of the v2 Management API.
Namespace
Auth0\SDK\API\ManagementCode
public function addUsers($role_id, array $users) {
$this
->checkEmptyOrInvalidString($role_id, 'role_id');
if (empty($users)) {
throw new EmptyOrInvalidParameterException('users');
}
$data = [
'users' => array_unique($users),
];
return $this->apiClient
->method('post')
->addPath('roles', $role_id)
->addPath('users')
->withBody(json_encode($data))
->call();
}