Constructor
new AuthenticationClient(options)
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
Options for the Authentication Client SDK.
|
Example
var AuthenticationClient = require('auth0'). AuthenticationClient;
var auth0 = new AuthenticationClient({
domain: '{YOUR_ACCOUNT}.auth0.com',
clientId: '{OPTIONAL_CLIENT_ID}'
});
Members
database :DatabaseAuthenticator
Database authenticator.
- Source:
Type:
-
DatabaseAuthenticator
oauth :OAuthAuthenticator
OAuth authenticator.
- Source:
Type:
-
OAuthAuthenticator
passwordless :PasswordlessAuthenticator
Passwordless authenticator.
- Source:
Type:
-
PasswordlessAuthenticator
Methods
changePassword(data) → {Promise|undefined}
Change password using a database or active directory service.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
User data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
email: '{EMAIL}',
password: '{PASSWORD}',
connection: 'Username-Password-Authentication'
};
auth0.changePassword(data, function (err, message) {
if (err) {
// Handle error.
}
console.log(message);
});
clientCredentialsGrant(options) → {Promise|undefined}
Gets an access token using the client credentials grant flow.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
|
Returns:
- Type:
-
Promise
|undefined
Example
auth0.clientCredentialsGrant({
audience: 'https://tenant.auth0.com/api/v2/',
scope: 'read:users update:users'
}, function (err, response) {
if (err) {
// Handle error.
}
console.log(response);
});
getClientInfo() → {Object}
Return an object with information about the current client,
- Source:
Returns:
- Type:
-
Object
Object containing client information.
getDelegationToken(data) → {Promise|undefined}
Exchange the token of the logged in user with a token that is valid to call the API (signed with the API secret).
- Source:
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
Token data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
id_token: '{ID_TOKEN}',
api_type: 'app',
target: '{TARGET}',
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer'
};
auth0.getDelegationToken(data, function (err, token) {
if (err) {
// Handle error.
}
console.log(token);
});
getProfile(accessToken) → {Promise|undefined}
Given an access token get the user profile linked to it.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
accessToken |
String
|
The user access token. |
Returns:
- Type:
-
Promise
|undefined
Example
auth0.getProfile(data, function (err, userInfo) {
if (err) {
// Handle error.
}
console.log(userInfo);
});
passwordGrant(userData) → {Promise|undefined}
Sign in using a username and password
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
userData |
Object
|
User credentials object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
client_id: '{CLIENT_ID}', // Optional field.
username: '{USERNAME}',
password: '{PASSWORD}'
realm: '{CONNECTION_NAME}', // Optional field.
scope: 'openid' // Optional field.
};
auth0.oauth.token(data, function (err, userData) {
if (err) {
// Handle error.
}
console.log(userData);
});
requestChangePasswordEmail(data) → {Promise|undefined}
Request a change password email using a database or active directory service.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
User data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
requestEmailCode(data) → {Promise|undefined}
Start passwordless flow sending an email.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
User data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
email: '{EMAIL}',
authParams: {} // Optional auth params.
};
auth0.requestEmailCode(data, function (err) {
if (err) {
// Handle error.
}
};
requestMagicLink(data) → {Promise|undefined}
Start passwordless flow sending an email.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
User data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
email: '{EMAIL}',
authParams: {} // Optional auth params.
};
auth0.requestMagicLink(data, function (err) {
if (err) {
// Handle error.
}
};
requestSMSCode(data) → {Promise|undefined}
Start passwordless flow sending an SMS.
- Source:
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
data |
Object
|
User data object.
|
Returns:
- Type:
-
Promise
|undefined
Example
var data = {
phone_number: '{PHONE}'
};
auth0.requestSMSCode(data, function (err) {
if (err) {
// Handle error.
}
});
verifySMSCode(data) → {Promise|undefined}
Sign in with the given user credentials.
- Source:
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object
|
Credentials object.
|
Returns:
- Type:
-
Promise
|undefined
Examples
var data = {
username: '{PHONE_NUMBER}',
password: '{VERIFICATION_CODE}'
};
auth0.verifySMSCode(data, function (err) {
if (err) {
// Handle error.
}
});
{
id_token: String,
access_token: String,
token_type: String
}