SHARE
TWEET

aws cognito

a guest Jun 8th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <title>Test</title>
  5.         <script src="js/aws-cognito-sdk.min.js"></script>
  6.         <script src="js/amazon-cognito-identity.min.js"></script>
  7.     </head>
  8.      <body>
  9.         <script>
  10.              var authenticationData = {
  11.         Username : 'testuser2',
  12.         Password : 'r123456',
  13.     };
  14.     var authenticationDetails = new AWSCognito.CognitoIdentityServiceProvider.AuthenticationDetails(authenticationData);
  15.     var poolData = { UserPoolId : 'us-east-2_mDShEFoEm',
  16.         ClientId : '335sugsn7i2o3rh0evtd62gshd'
  17.     };
  18.     var userPool = new AWSCognito.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
  19.     var userData = {
  20.         Username : 'testuser2',
  21.         Pool : userPool
  22.     };
  23.     var cognitoUser = new AWSCognito.CognitoIdentityServiceProvider.CognitoUser(userData);
  24.     cognitoUser.authenticateUser(authenticationDetails, {
  25.         onSuccess: function (result) {
  26.             console.log('access token + ' + result.getAccessToken().getJwtToken());
  27.             /*Use the idToken for Logins Map when Federating User Pools with Cognito Identity or when passing through an Authorization Header to an API Gateway Authorizer*/
  28.             console.log('idToken + ' + result.idToken.jwtToken);
  29.             console.log('yessss');
  30.         },
  31.  
  32.         onFailure: function(err) {
  33.             alert(err);
  34.         },
  35.  
  36.     });
  37.         </script>
  38.      </body>
  39. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top