Angular Auth0用户信息方法返回仅具有子属性的用户对象

Angular Auth0用户信息方法返回仅具有子属性的用户对象,angular,authentication,auth0,Angular,Authentication,Auth0,我正在为我的angular应用程序构建身份验证,当有人登录时,我正在尝试从auth0获取用户信息。我使用auth0文档作为指导,我得到了“user”对象,但它只有子属性,没有名称、电子邮件等 Object {sub: "auth0|5**********7"} 我尝试了facebook、linkedin、google登录,并在没有社交媒体的情况下注册,但结果都是一样的,只是“auth0”部分发生了变化。这是我的auth.service.ts: auth0 = new auth0.WebAuth

我正在为我的angular应用程序构建身份验证,当有人登录时,我正在尝试从auth0获取用户信息。我使用auth0文档作为指导,我得到了“user”对象,但它只有子属性,没有名称、电子邮件等

Object {sub: "auth0|5**********7"}
我尝试了facebook、linkedin、google登录,并在没有社交媒体的情况下注册,但结果都是一样的,只是“auth0”部分发生了变化。这是我的auth.service.ts:

auth0 = new auth0.WebAuth({
  clientID: 'myClientID',
  domain: 'myDomain.auth0.com',
  responseType: 'token id_token',
  audience: 'https://myDomain.auth0.com/userinfo',
  redirectUri: 'http://localhost:4200/',
  scope: 'openid'
})

handleAuthentication(): void {
  this.auth0.parseHash((err, authResult) => {
    if (authResult && authResult.accessToken && authResult.idToken) {
      window.location.hash = '';
      this.setSession(authResult);
      this.router.navigate(['/dersler']);

      // This is for getting user info after authentication (taken from the auth0 docs but revised)
      this.auth0.client.userInfo(authResult.accessToken, function(err, user) {
      // This method will make a request to the /userinfo endpoint 
      // and return the user object, which contains the user's information, 
        if (err) {
          return console.log(err);
        }
        console.log(user);
        return;
      });
      // method to get user info ends here

    } else if (err) {
      this.router.navigate(['/']);
      console.log(err);
    }
  });
}
我尝试在auth0文档中使用http方法获取userinfo,但它只返回具有“sub”属性的相同用户对象。为什么不返回其他用户信息

编辑(已解决):
我将auth0的“scope”属性从“openid”更改为“openid profile”,现在它成功返回带有名称和所有其他信息的用户对象。

问题在于您的
scope
参数,您可以将其更改为
scope:“openid profile email phone”
。然后注销,登录,就完成了


更多信息

您救了我们!我们两个人花了两天的时间,我只是看到了这一点,然后就明白了。你是个英雄,谢谢你!