Skip to content

Instantly share code, notes, and snippets.

@prasadjay
Created June 5, 2018 16:55
Show Gist options
  • Save prasadjay/2042d6cc28a3aff55690b5f5c3200d9a to your computer and use it in GitHub Desktop.
Save prasadjay/2042d6cc28a3aff55690b5f5c3200d9a to your computer and use it in GitHub Desktop.
Login-Cognito
function Login() {
var authenticationDetails = new AmazonCognitoIdentity.AuthenticationDetails({
Username : 'sampleEmail@gmail.com',
Password : 'SamplePassword123',
});
var userData = {
Username : 'sampleEmail@gmail.com',
Pool : userPool
};
var cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);
cognitoUser.authenticateUser(authenticationDetails, {
onSuccess: function (result) {
console.log('access token + ' + result.getAccessToken().getJwtToken());
console.log('id token + ' + result.getIdToken().getJwtToken());
console.log('refresh token + ' + result.getRefreshToken().getToken());
},
onFailure: function(err) {
console.log(err);
},
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment