UsersManager

auth. 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.

Methods

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);
});

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 aditional params.
};

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

  console.log(link);
});