Vue AWS Amplify无法获取凭证

时间:2020-04-26 12:52:32

标签: amazon-web-services vue.js authentication credentials aws-amplify

我正在使用AWS Amplify在Vue应用程序中进行身份验证。

我能够成功登录,但是无法使用Auth.currentUserCredentials()和Auth.currentCredentials()获取凭据。

我希望能帮助您解决问题。

我使用Amplify的Hub事件监听器监听授权事件的auth通道,并调试记录器。

在登录时,我注意到了这一点:

enter image description here

这是在开发人员模式下运行的,但是如果在网站上构建并运行,则会出现完全相同的错误。

似乎到本地主机的POST引起了问题。但是为什么在运行生产版本时会调用localhost?

这是从登录到调用Auth.currentCredentials()之后的整个日志:

enter image description here

enter image description here

这是登录表单的代码:

<amplify-authenticator>
  <div>
    My App
    <amplify-sign-out></amplify-sign-out>
  </div>
</amplify-authenticator>

这是我的aws-exports.js文件:

const awsmobile = {
"aws_project_region": "eu-west-1",
"aws_cognito_identity_pool_id": "eu-west-1:xyz....-4144-4b70-b021-e3486dbb1d43",
"aws_cognito_region": "eu-west-1",
"aws_user_pools_id": "eu-west-1_xyz....",
"aws_user_pools_web_client_id": "xyz....",
"oauth": {}

};

导出默认的awsmobile;

1 个答案:

答案 0 :(得分:0)

似乎有一个错误已得到修复,因此现在可以工作