为什么我在auth0.Management上收到错误403

时间:2019-05-16 11:29:51

标签: javascript ecmascript-6 auth0

我正在尝试使用auth0.Management API获取用户的个人资料 我收到了错误403,这是下面的代码

const a0 = new auth0.WebAuth({
  domain: process.env.AUTH0_DOMAIN,
  clientID: process.env.AUTH0_CLIENT_ID,
  responseType: 'token id_token',
  scope: 'openid profile email',
  redirectUri: window.location.href,
});

export function getUserUsingManagementApi() {
  a0.checkSession(
    {
      audience: 'https://' + process.env.AUTH0_DOMAIN + '/api/v2/',
      scope: 'read:current_user',
    },
    function(err, result) {
      if (!err) {
        const auth0Manage = new auth0.Management({
          domain: process.env.AUTH0_DOMAIN,
          token: result.accessToken,
        });
        auth0Manage.getUser(result.accessToken (err, userInfo) => {
          console.log('GET USER', err, userInfo);
        });
      }
      else {
        // handle error
      }
    }
  );
}

因此,我需要此信息以显示在用户页面上,并允许他们更新其姓名和电子邮件地址

enter console error screenshot

0 个答案:

没有答案