當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript auth0.ManagementClient類代碼示例

本文整理匯總了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.
  });
開發者ID:rchaser53,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:auth0-tests.ts

示例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.
  });
開發者ID:ErikSchierboom,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:auth0-tests.ts

示例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))
 })
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:8,代碼來源:auth0-tests.ts


注:本文中的auth0.ManagementClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。