搜索

首页  >  问答  >  正文

标题重写为:缺失的错误信息:缺少UserPoolId和ClientId

我正在研究在 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 文档尝试了多种方法。但仍然发生相同的错误,我的页面是空白的,控制台中出现错误。 检查了 Auth 选项,一切都很好。我该如何克服这个错误?我也没有使用任何客户端秘密哈希,因为 js sdk 无法与具有秘密哈希的应用程序客户端一起使用

P粉166675898P粉166675898464 天前637

全部回复(1)我来回复

  • P粉828463673

    P粉8284636732023-11-07 11:26:10

    配置参数的名称需要如下:

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

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

    回复
    0
  • 取消回复