【问题标题】:auth0 get all users from angular 2auth0 从角度 2 获取所有用户
【发布时间】:2016-10-28 20:39:21
【问题描述】:

我需要从 auth0 (https://auth0.com/docs/api/management/v2#!/Users/get_users) 从 anguler2 获取所有用户。 这是我试过的。我知道我必须在某处添加访问令牌。请指出正确的方向。

var headers: any = {
         'Accept': 'application/json',
         'Content-Type': 'application/json'
     };

     this.authHttp.get('https://nsrevo.au.auth0.com/api/v2/users?search_engine=v2', { headers: headers})
         .map(response => response.json())
         .subscribe(
             response => {
                 console.log(response);
             },
             error => alert(error.json().message)
         );

【问题讨论】:

    标签: angular jwt auth0


    【解决方案1】:

    在您的标头中,您需要使用 Management APIv2 token 添加 Authorization Bearer 标头(您应该安全地从服务器端脚本获取)才能成功调用此 API:

    Authorization: Bearer MGMT_API_TOKEN
    

    还要确保您获得的 Management APIv2 令牌具有您的应用程序所需的最小范围。在这种情况下,范围应该是 read:usersread:users read:user_idp_tokens,如 API docs 中所述。

    【讨论】:

      猜你喜欢
      • 2017-01-12
      • 1970-01-01
      • 2017-01-10
      • 2023-03-21
      • 2017-04-01
      • 2011-08-29
      • 1970-01-01
      • 2021-10-06
      • 2018-08-05
      相关资源
      最近更新 更多