我们在后端使用cognito的aws-appsync。默认情况下,它将使用用户名,密码和电子邮件字段进行登录/注册。因此,我们只有用于登录/注册的电话号码,而没有用户名和密码。因此,在后端,他们保留了自定义身份验证选项,以便我们可以传递自定义密钥而不是用户名和密码。
现在我已经使用了以下功能:
AWS.config.region = '****';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: '*******'
});
AWS.config.credentials.get(function(err) {
if (err) alert(JSON.stringify(err));
else alert(AWS.config.credentials);
});
var cognitoidentityserviceprovider = new
AWS.CognitoIdentityServiceProvider();
var params = {
AuthFlow : 'CUSTOM_AUTH',
ClientId: '******',
AuthParameters: {
USERNAME: '+91********'
}
}
cognitoidentityserviceprovider.initiateAuth(params, function(err, data){
if(err){
alert(JSON.stringify(err))
}else{
alert(JSON.stringify(data))
}
})
因此在这里,当用户不存在时,则其显示用户不存在错误 当给出给出的电话号码时,它会显示错误,例如无法识别的lambda输出。
所以,这里有两个问题,