Skip to content

Instantly share code, notes, and snippets.

@jeffski
Created March 31, 2017 01:47
Show Gist options
  • Save jeffski/cae28fc0da1b4c615569071a8f1b8432 to your computer and use it in GitHub Desktop.
Save jeffski/cae28fc0da1b4c615569071a8f1b8432 to your computer and use it in GitHub Desktop.
<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