首頁  >  問答  >  主體

標題重寫為:缺少的錯誤訊息:缺少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粉166675898347 天前558

全部回覆(1)我來回復

  • P粉828463673

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

    配置參數的名稱需要如下:

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

    在這裡定義:https://github.com/aws-amplify/amplify-js/blob/a047ce73abe98c3bf82e888c3afb4d2f911805f3/packages/auth/s#rc/types/Authts#L400

    回覆
    0
  • 取消回覆