Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function authenticateUserViaEmail() {
- log("authenticateUserViaEmail called");
- // Initialize the Amazon Cognito credentials provider
- AWS.config.region = 'us-east-1'; // Region
- AWS.config.credentials = new AWS.CognitoIdentityCredentials({
- IdentityPoolId: identityPoolId,
- });
- AWSCognito.config.region = 'us-east-1';
- AWSCognito.config.credentials = new AWS.CognitoIdentityCredentials({
- IdentityPoolId: identityPoolId,
- });
- var authenticationData = {
- Username : document.getElementById("email").value,
- Password : document.getElementById("password").value
- };
- log("using: " + JSON.stringify(authenticationData));
- var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
- var poolData = { UserPoolId : userPoolId,
- ClientId : clientId
- };
- var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
- var userData = {
- Username : document.getElementById("email").value,
- Pool : userPool
- };
- var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
- log("About to call authenticateUser...");
- cognitoUser.authenticateUser(authenticationDetails, {
- onSuccess: function (result) {
- log('Access token: ' + result.getAccessToken().getJwtToken());
- },
- onFailure: function(err) {
- log(err);
- console.error(err);
- },
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement