var authenticationData = { Username : 'myemail@example.com', Password : 'mypassword', }; var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails(authenticationData); var poolData = { UserPoolId : 'YOUR_USER_POOL_ID', // 用户池ID ClientId : 'YOUR_APP_CLIENT_ID' // 客户端ID }; var userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); var userData = { Username : 'myemail@example.com', // 字段必须与Username相同 Pool : userPool }; var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); cognitoUser.authenticateUser(authenticationDetails, { onSuccess: function (result) { console.log('authentication successful!'); }, onFailure: function(err) { console.log(err); }, });