Created
March 31, 2017 01:47
-
-
Save jeffski/cae28fc0da1b4c615569071a8f1b8432 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Cognito Sign In Example</title> | |
<script src="https://rawgit.com/aws/amazon-cognito-identity-js/master/dist/aws-cognito-sdk.min.js"></script> | |
<script src="https://rawgit.com/aws/amazon-cognito-identity-js/master/dist/amazon-cognito-identity.min.js"></script> | |
<script> | |
var CognitoUserPool = AmazonCognitoIdentity.CognitoUserPool; | |
var poolData = { | |
UserPoolId : 'ap-southeast-2_EPyUfpQq7', // Your user pool id | |
ClientId : '54o2tsorf2j0adkefbbnhdhj3m' // Your app client id | |
}; | |
var userPool = new CognitoUserPool(poolData); | |
document.addEventListener('DOMContentLoaded', function() { | |
var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails({ | |
Username : 'testuser', | |
Password : 'P@55w0rd' | |
}); | |
var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser({ | |
Username : 'testuser', | |
Pool : userPool | |
}); | |
cognitoUser.authenticateUser(authenticationDetails, { | |
onSuccess: function (result) { | |
console.log(result); | |
}, | |
onFailure: function(err) { | |
console.log(err); | |
} | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment