Javascript getUserAttributes()引发未授权异常

Javascript getUserAttributes()引发未授权异常,javascript,amazon-web-services,amazon-cognito,Javascript,Amazon Web Services,Amazon Cognito,我试图从我的Cognito池中的第三方用户那里获取用户属性。 我可以使用Auth.currentAuthenticatedUser()获取没有属性的用户,但返回的CognitoUser对象上没有属性。我读过的文档建议在该CognitoUserInstance上调用.getUserAttributes,但是,每当我尝试这样做时,就会出现400错误 示例代码: const user = await Auth.currentAuthenticatedUser() // console.log(user

我试图从我的Cognito池中的第三方用户那里获取用户属性。 我可以使用Auth.currentAuthenticatedUser()获取没有属性的用户,但返回的CognitoUser对象上没有属性。我读过的文档建议在该CognitoUserInstance上调用.getUserAttributes,但是,每当我尝试这样做时,就会出现400错误

示例代码:

const user = await Auth.currentAuthenticatedUser()
// console.log(user) // user is indeed a CognitoUser object.
await user.getUserAttributes((x) => {
  console.log({ x });
})

// x: {
//     code: "NotAuthorizedException"
//     message: "Access Token does not have required scopes"
//     name: "NotAuthorizedException"
//    }
我的所有用户池属性当前都已启用读/写权限。我如何给这个用户访问令牌所需的作用域以获取并返回他们自己的属性