Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```
- const login = () => {
- let Username = 'reacttest';
- let Password = 'reacttest';
- let authenticationDetails = new AuthenticationDetails({
- Username,
- Password
- });
- const { UserPoolId, ClientId } = config;
- var poolData = { UserPoolId, ClientId };
- var userPool = new CognitoUserPool(poolData);
- var userData = {
- Username : 'reacttest',
- Pool : userPool
- };
- var cognitoUser = new CognitoUser(userData);
- cognitoUser.authenticateUser(authenticationDetails, {
- onSuccess: function (result) {
- AWS.config.credentials = new AWS.CognitoIdentityCredentials({
- IdentityPoolId : config.IdentityPoolId, // your identity pool id here
- Logins : {
- ['cognito-idp.' + config.region + '.amazonaws.com/' + config.UserPoolId] : result.getIdToken().getJwtToken()
- }
- });
- AWS.config.credentials.get(function() {
- console.log('AWS.config', AWS.config.credentials);
- var apigClient = window.apigClientFactory.newClient({
- accessKey: AWS.config.credentials.accessKeyId,
- secretKey: AWS.config.credentials.secretAccessKey,
- sessionToken: AWS.config.sessionToken, //OPTIONAL: If you are using temporary credentials you must include the session token
- region: config.region // OPTIONAL: The region where the API is deployed, by default this parameter is set to us-east-1
- });
- // apigClient.identityGet({}, {}, {});
- apigClient.identityGet({}, {}, {});
- });
- },
- onFailure: function(err) {
- alert(err);
- },
- });
- };
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement