本文整理匯總了TypeScript中auth0.ManagementClient類的典型用法代碼示例。如果您正苦於以下問題:TypeScript ManagementClient類的具體用法?TypeScript ManagementClient怎麽用?TypeScript ManagementClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ManagementClient類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
/// <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.
});
示例2:
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}',
clientSecret: '{OPTIONAL_CLIENT_SECRET}'
});
// 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.
});
示例3:
.then((smsUser) => {
if (!smsUser) return;
const userId = emailUser.user_id;
const params = { user_id: smsUser.user_id, provider: 'sms' };
management.linkUsers(userId, params)
.catch(err => console.error('Cannot link E-mail and SMS users', err))
.then((linkedUsers) => console.log(linkedUsers))
})