UsersManager

UsersManager

Provides methods for getting user information and impersonating users.

Constructor

new UsersManager(options)

Source:
Parameters:
Name Type Description
options object

Manager options.

Name Type Attributes Description
baseUrl string

The auth0 account URL.

headers string <optional>

Default request headers.

clientId string <optional>

Default client ID.

Members

authenticators :external:RestClient

For CRUD on user's authenticators

Source:
Type:

enrollments :external:RestClient

Provides an abstraction layer for retrieving Guardian enrollments.

Source:
Type:

identities :external:RestClient

Provides a simple abstraction layer for linking user accounts.

Source:
Type:

invalidateRememberBrowsers :external:RestClient

Provides an abstraction layer for invalidating all remembered browsers for MFA.

Source:
Type:

multifactor :external:RestClient

Provides an abstraction layer for consuming the Multifactor Provider endpoint.

Source:
Type:

permissions :external:RestClient

Provides an abstraction layer for CRD on permissions directly on a user

Source:
Type:

recoveryCodeRegenerations :external:RestClient

Provides an abstraction layer for regenerating Guardian recovery codes.

Source:
Type:

roles :external:RestClient

Provides an abstraction layer for CRD on roles for a user

Source:
Type:

userLogs :external:RestClient

Provides a simple abstraction layer for user logs

Source:
Type:

usersByEmail :external:RestClient

Provides an abstraction layer for the new "users-by-email" API

Source:
Type:

Methods

assignPermissions(params, data, cbopt) → {Promise|undefined}

Assign permissions to a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of permissions

Name Type Description
permissions string

Array of permission IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};

management.users.assignPermissions(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // permissions added.
});

assignRoles(params, data, cbopt) → {Promise|undefined}

Assign roles to a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of role IDs

Name Type Description
roles string

Array of role IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "roles" : ["roleId1", "roleID2"]};

management.users.assignRoles(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // roles added.
});

create(data, cbopt) → {Promise|undefined}

Create a new user.

Source:
Parameters:
Name Type Attributes Description
data object

User data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.create(data, function (err) {
  if (err) {
    // Handle error.
  }

  // User created.
});

createAuthenticationMethod(params, data, cbopt) → {Promise|undefined}

Creates an authentication method for a given user.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

data object

Authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

delete(params, cbopt) → {Promise|undefined}

Delete a user by its id.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.delete({ id: USER_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // User deleted.
});

deleteAll(cbopt) → {Promise|undefined}

Delete all users.

Deprecated:
  • This method will be removed in the next major release.
Source:
Parameters:
Name Type Attributes Description
cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.deleteAll(function (err) {
  if (err) {
    // Handle error.
  }

  // Users deleted
});

deleteAuthenticationMethodById(params, data, cbopt) → {Promise|undefined}

Deletes an authentication method by ID.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

deleteAuthenticationMethods(params, cbopt) → {Promise|undefined}

Deletes all authentication methods for the given user.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

Delete a multifactor provider.

Source:
Parameters:
Name Type Attributes Description
params object

Data object.

Name Type Description
id string

The user id.

provider string

Multifactor provider.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };

management.users.deleteMultifactorProvider(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

get(data, cbopt) → {Promise|undefined}

Get a user by its id.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.get({ id: USER_ID }, function (err, user) {
  console.log(user);
});

getAll(paramsopt, cbopt) → {Promise|undefined}

Get all users.

Source:
Parameters:
Name Type Attributes Description
params object <optional>

Users params.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings and the search query. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0
};

management.users.getAll(params, function (err, users) {
  console.log(users.length);
});

getAuthenticationMethodById(params, cbopt) → {Promise|undefined}

Gets an authentication method by ID.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

getAuthenticationMethods(params, cbopt) → {Promise|undefined}

Gets a list of authentication methods.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

getByEmail(emailopt, optionsopt, cbopt) → {Promise|undefined}

Get Users by an Email Address

Source:
Parameters:
Name Type Attributes Description
email string <optional>

Email address of user(s) to find

options object <optional>

Additional options to pass to the endpoint

Name Type Attributes Description
fields string <optional>

Comma-separated list of fields to include or exclude in the result

include_fields boolean <optional>

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes a first argument as the Email address to look for users, and uses the /users-by-email API, not the search API

management.users.getByEmail('email@address', function (err, users) {
  console.log(users);
});

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

Get a list of Guardian enrollments.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
  console.log(enrollments);
});

getInfo(accessToken, cbopt) → {Promise|undefined}

Given an access token get the user profile linked to it.

Source:
Parameters:
Name Type Attributes Description
accessToken string

User access token.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

Get the user information based on the Auth0 access token (obtained during login). Find more information in the API Docs.

auth0.users.getInfo(accessToken, function (err, userInfo) {
  if (err) {
    // Handle error.
  }

  console.log(userInfo);
});

getPermissions(data, cbopt) → {Promise|undefined}

Get a list of permissions for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getPermissions({ id: USER_ID }, function (err, permissions) {
  console.log(permissions);
});

getRoles(data, cbopt) → {Promise|undefined}

Get a list of roles for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getRoles({ id: USER_ID }, function (err, roles) {
  console.log(roles);
});

getUserOrganizations(data, cbopt) → {Promise|undefined}

Get a list of organizations for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) {
  console.log(orgs);
});

impersonate(userId, settings, cbopt) → {Promise|undefined}

Impersonate the user with the given user ID.

Source:
Parameters:
Name Type Attributes Description
userId string

User ID token.

settings object

Impersonation settings.

Name Type Attributes Description
impersonator_id string

Impersonator user ID.

protocol string

The authentication protocol.

token string

API v1 token obtained for impersonation

clientId string <optional>

Client id used for impersonation. Uses the one supplied in the constructor by default.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

Gets a link that can be used once to log in as a specific user. Useful for troubleshooting. Find more information in the [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate).

var settings = {
  impersonator_id: '{IMPERSONATOR_ID}',
  protocol: 'oauth2',
  additionalParameters: {}  // Optional additional params.
};

auth0.users.impersonate(userId, settings, function (err, link) {
  if (err) {
    // Handle error.
  }

  console.log(link);
});

invalidateRememberBrowser(params, cbopt) → {Promise|undefined}

Invalidate all remembered browsers for MFA.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) {
  if (err) {
    // Handle error.
  }

  // Invalidated all remembered browsers.
});

Link the user with another account.

Source:
Parameters:
Name Type Attributes Description
userId string

ID of the primary user.

params object

Secondary user data.

Name Type Description
user_id string

ID of the user to be linked.

connection_id string

ID of the connection to be used.

provider string

Identity provider of the secondary user account being linked.

link_with string

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var userId = 'USER_ID';
var params = {
  user_id: 'OTHER_USER_ID',
  connection_id: 'CONNECTION_ID'
};

management.users.link(userId, params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users linked.
});

logs(params, cbopt) → {Promise|undefined}

Get user's log events.

Source:
Parameters:
Name Type Attributes Description
params object

Get logs data.

Name Type Description
id string

User id.

per_page number

Number of results per page.

page number

Page number, zero indexed.

sort string

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

include_totals boolean

true if a query summary must be included in the result, false otherwise. Default false;

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };

management.users.logs(params, function (err, logs) {
  if (err) {
    // Handle error.
  }

  console.log(logs);
});

regenerateRecoveryCode(params, cbopt) → {Promise|undefined}

Generate new Guardian recovery code.

Source:
Parameters:
Name Type Attributes Description
params object

Get logs data.

Name Type Description
id string

User id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
  console.log(result.recovery_code);
});

removePermissions(params, data, cbopt) → {Promise|undefined}

Remove permissions from a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data object

data object containing list of permission IDs

Name Type Description
permissions string

Array of permission IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};

management.users.removePermissions(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // permissions removed.
});

removeRoles(params, data, cbopt) → {Promise|undefined}

Remove roles from a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of role IDs

Name Type Description
roles string

Array of role IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "roles" : ["roleId1", "roleID2"]};

management.users.removeRoles(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // roles removed.
});

Unlink the given accounts.

Source:
Parameters:
Name Type Attributes Description
params object

Linked users data.

Name Type Description
id string

Primary user ID.

provider string

Identity provider in use.

user_id string

Secondary user ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };

management.users.unlink(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

update(params, data, cbopt) → {Promise|undefined}

Update a user by its id.

Source:
Parameters:
Name Type Attributes Description
params object

The user parameters.

Name Type Description
id string

The user id.

data object

New user data.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };

management.users.update(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the app metadata.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

metadata object

New app metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  foo: 'bar'
};

management.users.updateAppMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateAuthenticationMethodById(params, data, cbopt) → {Promise|undefined}

Updates an authentication method.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

updateAuthenticationMethods(params, data, cbopt) → {Promise|undefined}

Updates all authentication methods for a user by replacing them with the given ones.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the user metadata.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

metadata object

New user metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  address: '123th Node.js Street'
};

management.users.updateUserMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

UsersManager

Abstracts interaction with the users endpoint.

Constructor

new UsersManager(options)

Source:
Parameters:
Name Type Description
options object

The client options.

Name Type Attributes Description
baseUrl string

The URL of the API.

headers object <optional>

Headers to be included in all requests.

retry object <optional>

Retry Policy Config

Members

authenticators :external:RestClient

For CRUD on user's authenticators

Source:
Type:

enrollments :external:RestClient

Provides an abstraction layer for retrieving Guardian enrollments.

Source:
Type:

identities :external:RestClient

Provides a simple abstraction layer for linking user accounts.

Source:
Type:

invalidateRememberBrowsers :external:RestClient

Provides an abstraction layer for invalidating all remembered browsers for MFA.

Source:
Type:

multifactor :external:RestClient

Provides an abstraction layer for consuming the Multifactor Provider endpoint.

Source:
Type:

permissions :external:RestClient

Provides an abstraction layer for CRD on permissions directly on a user

Source:
Type:

recoveryCodeRegenerations :external:RestClient

Provides an abstraction layer for regenerating Guardian recovery codes.

Source:
Type:

roles :external:RestClient

Provides an abstraction layer for CRD on roles for a user

Source:
Type:

userLogs :external:RestClient

Provides a simple abstraction layer for user logs

Source:
Type:

usersByEmail :external:RestClient

Provides an abstraction layer for the new "users-by-email" API

Source:
Type:

Methods

assignPermissions(params, data, cbopt) → {Promise|undefined}

Assign permissions to a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of permissions

Name Type Description
permissions string

Array of permission IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};

management.users.assignPermissions(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // permissions added.
});

assignRoles(params, data, cbopt) → {Promise|undefined}

Assign roles to a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of role IDs

Name Type Description
roles string

Array of role IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "roles" : ["roleId1", "roleID2"]};

management.users.assignRoles(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // roles added.
});

create(data, cbopt) → {Promise|undefined}

Create a new user.

Source:
Parameters:
Name Type Attributes Description
data object

User data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.create(data, function (err) {
  if (err) {
    // Handle error.
  }

  // User created.
});

createAuthenticationMethod(params, data, cbopt) → {Promise|undefined}

Creates an authentication method for a given user.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

data object

Authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

delete(params, cbopt) → {Promise|undefined}

Delete a user by its id.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.delete({ id: USER_ID }, function (err) {
  if (err) {
    // Handle error.
  }

  // User deleted.
});

deleteAll(cbopt) → {Promise|undefined}

Delete all users.

Deprecated:
  • This method will be removed in the next major release.
Source:
Parameters:
Name Type Attributes Description
cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
management.users.deleteAll(function (err) {
  if (err) {
    // Handle error.
  }

  // Users deleted
});

deleteAuthenticationMethodById(params, data, cbopt) → {Promise|undefined}

Deletes an authentication method by ID.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

deleteAuthenticationMethods(params, cbopt) → {Promise|undefined}

Deletes all authentication methods for the given user.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

deleteMultifactorProvider(params, cbopt) → {Promise|undefined}

Delete a multifactor provider.

Source:
Parameters:
Name Type Attributes Description
params object

Data object.

Name Type Description
id string

The user id.

provider string

Multifactor provider.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: MULTIFACTOR_PROVIDER };

management.users.deleteMultifactorProvider(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

get(data, cbopt) → {Promise|undefined}

Get a user by its id.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.get({ id: USER_ID }, function (err, user) {
  console.log(user);
});

getAll(paramsopt, cbopt) → {Promise|undefined}

Get all users.

Source:
Parameters:
Name Type Attributes Description
params object <optional>

Users params.

Name Type Attributes Description
per_page number <optional>

Number of results per page.

page number <optional>

Page number, zero indexed.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes an optional object as first argument that may be used to specify pagination settings and the search query. If pagination options are not present, the first page of a limited number of results will be returned.

// Pagination settings.
var params = {
  per_page: 10,
  page: 0
};

management.users.getAll(params, function (err, users) {
  console.log(users.length);
});

getAuthenticationMethodById(params, cbopt) → {Promise|undefined}

Gets an authentication method by ID.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

getAuthenticationMethods(params, cbopt) → {Promise|undefined}

Gets a list of authentication methods.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

getByEmail(emailopt, optionsopt, cbopt) → {Promise|undefined}

Get Users by an Email Address

Source:
Parameters:
Name Type Attributes Description
email string <optional>

Email address of user(s) to find

options object <optional>

Additional options to pass to the endpoint

Name Type Attributes Description
fields string <optional>

Comma-separated list of fields to include or exclude in the result

include_fields boolean <optional>

Whether specified fields are to be included (true) or excluded (false). Defaults to true.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

This method takes a first argument as the Email address to look for users, and uses the /users-by-email API, not the search API

management.users.getByEmail('email@address', function (err, users) {
  console.log(users);
});

getGuardianEnrollments(data, cbopt) → {Promise|undefined}

Get a list of Guardian enrollments.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getGuardianEnrollments({ id: USER_ID }, function (err, enrollments) {
  console.log(enrollments);
});

getInfo(accessToken, cbopt) → {Promise|undefined}

Given an access token get the user profile linked to it.

Source:
Parameters:
Name Type Attributes Description
accessToken string

User access token.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

Get the user information based on the Auth0 access token (obtained during login). Find more information in the API Docs.

auth0.users.getInfo(accessToken, function (err, userInfo) {
  if (err) {
    // Handle error.
  }

  console.log(userInfo);
});

getPermissions(data, cbopt) → {Promise|undefined}

Get a list of permissions for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getPermissions({ id: USER_ID }, function (err, permissions) {
  console.log(permissions);
});

getRoles(data, cbopt) → {Promise|undefined}

Get a list of roles for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getRoles({ id: USER_ID }, function (err, roles) {
  console.log(roles);
});

getUserOrganizations(data, cbopt) → {Promise|undefined}

Get a list of organizations for a user.

Source:
Parameters:
Name Type Attributes Description
data object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.getUserOrganizations({ id: USER_ID }, function (err, orgs) {
  console.log(orgs);
});

impersonate(userId, settings, cbopt) → {Promise|undefined}

Impersonate the user with the given user ID.

Source:
Parameters:
Name Type Attributes Description
userId string

User ID token.

settings object

Impersonation settings.

Name Type Attributes Description
impersonator_id string

Impersonator user ID.

protocol string

The authentication protocol.

token string

API v1 token obtained for impersonation

clientId string <optional>

Client id used for impersonation. Uses the one supplied in the constructor by default.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example

Gets a link that can be used once to log in as a specific user. Useful for troubleshooting. Find more information in the [API Docs](https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate).

var settings = {
  impersonator_id: '{IMPERSONATOR_ID}',
  protocol: 'oauth2',
  additionalParameters: {}  // Optional additional params.
};

auth0.users.impersonate(userId, settings, function (err, link) {
  if (err) {
    // Handle error.
  }

  console.log(link);
});

invalidateRememberBrowser(params, cbopt) → {Promise|undefined}

Invalidate all remembered browsers for MFA.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.invalidateRememberBrowser({ id: USER_ID }, function (err, result) {
  if (err) {
    // Handle error.
  }

  // Invalidated all remembered browsers.
});

Link the user with another account.

Source:
Parameters:
Name Type Attributes Description
userId string

ID of the primary user.

params object

Secondary user data.

Name Type Description
user_id string

ID of the user to be linked.

connection_id string

ID of the connection to be used.

provider string

Identity provider of the secondary user account being linked.

link_with string

JWT for the secondary account being linked. If sending this parameter, provider, user_id, and connection_id must not be sent.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var userId = 'USER_ID';
var params = {
  user_id: 'OTHER_USER_ID',
  connection_id: 'CONNECTION_ID'
};

management.users.link(userId, params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users linked.
});

logs(params, cbopt) → {Promise|undefined}

Get user's log events.

Source:
Parameters:
Name Type Attributes Description
params object

Get logs data.

Name Type Description
id string

User id.

per_page number

Number of results per page.

page number

Page number, zero indexed.

sort string

The field to use for sorting. Use field:order where order is 1 for ascending and -1 for descending. For example date:-1.

include_totals boolean

true if a query summary must be included in the result, false otherwise. Default false;

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, page: 0, per_page: 50, sort: 'date:-1', include_totals: true };

management.users.logs(params, function (err, logs) {
  if (err) {
    // Handle error.
  }

  console.log(logs);
});

regenerateRecoveryCode(params, cbopt) → {Promise|undefined}

Generate new Guardian recovery code.

Source:
Parameters:
Name Type Attributes Description
params object

Get logs data.

Name Type Description
id string

User id.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
management.users.regenerateRecoveryCode("USER_ID", function (err, result) {
  console.log(result.recovery_code);
});

removePermissions(params, data, cbopt) → {Promise|undefined}

Remove permissions from a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data object

data object containing list of permission IDs

Name Type Description
permissions string

Array of permission IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "permissions" : [{"permission_name" :"do:something" ,"resource_server_identifier" :"test123" }]};

management.users.removePermissions(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // permissions removed.
});

removeRoles(params, data, cbopt) → {Promise|undefined}

Remove roles from a user

Source:
Parameters:
Name Type Attributes Description
params object

params object

Name Type Description
id string

user_id

data string

data object containing list of role IDs

Name Type Description
roles string

Array of role IDs

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params =  { id : 'USER_ID';
var data = { "roles" : ["roleId1", "roleID2"]};

management.users.removeRoles(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // roles removed.
});

Unlink the given accounts.

Source:
Parameters:
Name Type Attributes Description
params object

Linked users data.

Name Type Description
id string

Primary user ID.

provider string

Identity provider in use.

user_id string

Secondary user ID.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID, provider: 'auht0', user_id: OTHER_USER_ID };

management.users.unlink(params, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Users accounts unlinked.
});

update(params, data, cbopt) → {Promise|undefined}

Update a user by its id.

Source:
Parameters:
Name Type Attributes Description
params object

The user parameters.

Name Type Description
id string

The user id.

data object

New user data.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };

management.users.update(params, data, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateAppMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the app metadata.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

metadata object

New app metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  foo: 'bar'
};

management.users.updateAppMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});

updateAuthenticationMethodById(params, data, cbopt) → {Promise|undefined}

Updates an authentication method.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

authentication_method_id string

The authentication method id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

updateAuthenticationMethods(params, data, cbopt) → {Promise|undefined}

Updates all authentication methods for a user by replacing them with the given ones.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object.

Name Type Description
id string

The user id.

data object

Updated authentication method data.

cb function <optional>

Callback function.

Returns:
Type:
Promise | undefined

updateUserMetadata(params, metadata, cbopt) → {Promise|undefined}

Update the user metadata.

Source:
Parameters:
Name Type Attributes Description
params object

The user data object..

Name Type Description
id string

The user id.

metadata object

New user metadata.

cb function <optional>

Callback function

Returns:
Type:
Promise | undefined
Example
var params = { id: USER_ID };
var metadata = {
  address: '123th Node.js Street'
};

management.users.updateUserMetadata(params, metadata, function (err, user) {
  if (err) {
    // Handle error.
  }

  // Updated user.
  console.log(user);
});