mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
52 lines
985 B
TypeScript
52 lines
985 B
TypeScript
/// <reference types="auth0" />
|
|
|
|
import * as auth0 from 'auth0';
|
|
|
|
const management = new auth0.ManagementClient({
|
|
token: '{YOUR_API_V2_TOKEN}',
|
|
domain: '{YOUR_ACCOUNT}.auth0.com'
|
|
});
|
|
|
|
const auth = new auth0.AuthenticationClient({
|
|
domain: '{YOUR_ACCOUNT}.auth0.com',
|
|
clientId: '{OPTIONAL_CLIENT_ID}'
|
|
});
|
|
|
|
// Using a callback.
|
|
management.getUsers((err: Error, users: auth0.User[]) => {
|
|
if (err) {
|
|
// Handle error.
|
|
}
|
|
console.log(users);
|
|
});
|
|
|
|
// Using a Promise.
|
|
management
|
|
.getUsers()
|
|
.then((users) => {
|
|
console.log(users);
|
|
})
|
|
.catch((err) => {
|
|
// Handle the error.
|
|
});
|
|
|
|
management
|
|
.createUser({
|
|
connection: 'My-Connection',
|
|
email: 'hi@me.co',
|
|
}).then((user) => {
|
|
console.log(user);
|
|
}).catch((err) => {
|
|
// Handle the error.
|
|
});
|
|
|
|
auth
|
|
.requestChangePasswordEmail({
|
|
connection: 'My-Connection',
|
|
email: 'hi@me.co',
|
|
}).then((response) => {
|
|
console.log(response);
|
|
}).catch((err) => {
|
|
// Handle the error.
|
|
});
|