Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.authCognitoUser = function(theUserPoolID, theClientID, userName, userPassword) {
- var authenticationData = {
- Username : userName,
- Password : userPassword
- };
- var authenticationDetails = new AWSCognito.AuthenticationDetails(authenticationData);
- var poolData = { UserPoolId : theUserPoolID,
- ClientId : theClientID
- };
- var userPool = new AWSCognito.CognitoUserPool(poolData);
- var userData = {
- Username : userName,
- Pool : userPool
- };
- console.log('authentication details: ',authenticationDetails);
- var cognitoUser = new AWSCognito.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());
- return result;
- },
- onFailure: function(err) {
- console.log(err.message || JSON.stringify(err));
- return err;
- },
- });
- }
- authentication details: AuthenticationDetails {
- validationData: {},
- authParameters: {},
- username: 'thesmarterstuff',
- password: 'passW0rd!’ }
Add Comment
Please, Sign In to add comment