Created
June 5, 2018 16:55
-
-
Save prasadjay/2042d6cc28a3aff55690b5f5c3200d9a to your computer and use it in GitHub Desktop.
Login-Cognito
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
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