【问题标题】:Uncaught Error: Both UserPoolId and ClientId are required未捕获的错误:UserPoolId 和 ClientId 都是必需的
【发布时间】:2021-09-13 08:32:24
【问题描述】:

我正在努力在 vue js 应用程序中放大身份验证以使用 cognito 登录,以下是我在 main.js 中添加的代码:

import Amplify from 'aws-amplify';
Amplify.configure({
      Auth: {
        mandatorySignIn: false,
        region: config.cognito.REGION,
        userPoolId: config.cognito.USER_POOL_ID,
        UserPoolClientId: config.cognito.APP_CLIENT_ID,
      },
    });

但不知何故我收到了这种错误:

CognitoUserPool.js?17a7:46 Uncaught Error: Both UserPoolId and ClientId are required.
    at new CognitoUserPool (CognitoUserPool.js?17a7:46)
    at AuthClass.configure (Auth.js?bf82:183)
    at eval (Amplify.js?7d03:83)
    at Array.map (<anonymous>)
    at AmplifyClass.configure (Amplify.js?7d03:82)
    at eval (main.js?56d7:15)
    at Module../src/main.js (app.js:1692)
    at __webpack_require__ (app.js:854)
    at fn (app.js:151)
    at Object.1 (app.js:2809)

按照参考视频和 aws amplify 文档,我尝试了多种方法。但仍然发生同样的错误,我的页面是空白的,控制台出现错误。 检查了身份验证选项,一切都很好。我该如何克服这个错误?我也没有使用任何客户端秘密哈希,因为 js sdk 没有与带有秘密哈希的应用程序客户端一起使用

【问题讨论】:

    标签: javascript vue.js amazon-cognito aws-amplify


    【解决方案1】:

    配置参数名称需要是

    ...
    userPoolId: '...'
    userPoolWebClientId: '...'
    ...
    

    这里定义:https://github.com/aws-amplify/amplify-js/blob/a047ce73abe98c3bf82e888c3afb4d2f911805f3/packages/auth/src/types/Auth.ts#L40

    【讨论】:

      猜你喜欢
      • 2021-02-27
      • 2020-04-13
      • 2016-02-17
      • 1970-01-01
      • 2017-07-09
      • 2018-03-22
      • 1970-01-01
      • 2015-06-01
      • 2016-05-17
      相关资源
      最近更新 更多