我正在尝试使用 AWS Cognito 进行自定义身份验证流程,以便我可以通过电子邮件而不是通过 cognito 触发器发送 MFA 代码。我正在使用initialAuth()方法来执行此操作,根据文档这是正确的;
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_InitiateAuth.html https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CognitoIdentityServiceProvider.html#initiateAuth -财产
我的有效负载似乎是有效的,但是当我尝试使用用户登录时,我收到错误“t.getauthparameters 不是函数”
我浏览了其他一些stackoverflow帖子,但没有任何帮助
任何想法出了什么问题?
这是我下面代码的一个片段:
const payload = {
AuthFlow: 'CUSTOM_AUTH',
ClientId: 'my client id',
AuthParameters: {
USERNAME: $('input[name=username]').val(),
PASSWORD: $('input[name=password]').val(),
CHALLENGE_NAME: 'SRP_A'
}
};
cognitoUser.initiateAuth(payload, {
onSuccess: function(result) {
// User authentication was successful
},
onFailure: function(err) {
// User authentication was not successful
},
customChallenge: function(challengeParameters) {
// User authentication depends on challenge response
var verificationCode = prompt('Please input OTP code' ,'');
cognitoUser.sendCustomChallengeAnswer(verificationCode, this);
},
});