0

我正在使用 Cognito 创建关于登录 OTP 页面(我们的项目登录系统已经使用 Cognito 用户池)

我坚持 Cognito OTP 工作

[这是我的行动历史]

  • 我当前的 Cognito Userpool MFA 设置:“可选”
  • 节点.js
  • 登录逻辑已创建。[我们的项目模块使用如下]
import { Config, CognitoIdentityCredentials, CognitoIdentityServiceProvider } from 'aws-sdk';
import {
 CognitoUserPool,
 CognitoUser,
 AuthenticationDetails,
 CognitoUserAttribute
} from 'amazon-cognito-identity-js'; 
  • 登录逻辑完成后,调用 AWS Cognito TOTP API 启动 MFA AssociateSoftwareToken()
  • 当我使用“AssociateSoftwareToken()”时出现错误 CredentialsError: Missing credentials in config
const cognitoServiceProvider = new CognitoIdentityServiceProvider({region:this.options.region});
         cognitoServiceProvider.associateSoftwareToken(params, function(err, data) {
           if (err) console.log(err, err.stack); // an error occurred
           else     console.log(data);           // successful response
         });
  1. 所以我插入了一些代码来修复这个凭据问题,如下所示,并且发生了另一个错误。

Amazon Cognito 的用户池 - CredentialsError: Missing credentials in config -> 此评论说需要 AWS.config 和 AWSConfig.config 设置。

    Config.region = config.region;
    Config.credentials = new CognitoIdentityCredentials({
      IdentityPoolId: config.IdentityPoolId
    });
    AWSCognito.config.region = config.region;
    AWSCognito.config.credentials = new CognitoIdentityCredentials({
    IdentityPoolId: config.IdentityPoolId
});
  1. 但是错误显示ReferenceError: AWSCognito is not defined 我知道 AWS.config 是从 aws-sdk 模块提供的,但是我该如何解决以提供 AWSCognito ?请帮忙
4

0 回答 0