Constructor
new UsersManager(options)
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object
|
Manager options.
|
Members
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:
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
|
|||||||
data |
string
|
data object containing list of permissions
|
|||||||
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
|
|||||||
data |
string
|
data object containing list 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.
|
|||||||
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..
|
|||||||
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.
|
||||||||||
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.
|
|||||||
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.
|
||||||||||
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.
|
|||||||
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.
|
||||||||||||
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.
|
||||||||||
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.
|
|||||||
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
|
||||||||||||
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.
|
|||||||
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.
|
|||||||
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.
|
|||||||
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.
|
|||||||
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.
|
|||||||||||||||||||||
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.
|
|||||||
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(userId, params, cbopt) → {Promise|undefined}
Link the user with another account.
- Source:
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
userId |
string
|
ID of the primary user. |
||||||||||||||||
params |
object
|
Secondary user data.
|
||||||||||||||||
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.
|
|||||||||||||||||||
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.
|
|||||||
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
|
|||||||
data |
object
|
data object containing list 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
|
|||||||
data |
string
|
data object containing list 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(params, cbopt) → {Promise|undefined}
Unlink the given accounts.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object
|
Linked users data.
|
|||||||||||||
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.
|
|||||||
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..
|
|||||||
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.
|
||||||||||
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.
|
|||||||
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..
|
|||||||
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);
});