AmazonCognito身份验证失败,出现NotAuthorizedException:用户名和密码不正确

时间:2017-03-29 18:24:56

标签: amazon-cognito

我正在尝试对用户进行身份验证,并且使用NotAuthorizedException失败:用户名和密码不正确。

我确实检查过用户已注册并确认,我不知道我可能遗失的内容。

var authenticationData = {
    Username: 'username',
    Password: 'password',
};
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
var poolData = {
    UserPoolId: 'userpoolid',
    ClientId: 'clientid'
};
var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
var userData = {
    Username: 'username',
    Pool: userPool
};
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
    onSuccess: function (result) {
        alert("Success");
        console.log('access token + ' + result.getAccessToken().getJwtToken());
        /*Use the idToken for Logins Map when Federating User Pools with Cognito Identity or when passing through an Authorization Header to an API Gateway Authorizer*/
        console.log('idToken + ' + result.idToken.jwtToken);
    },

    onFailure: function (err) {
        alert(err);
    },

});

0 个答案:

没有答案
相关问题