Created
September 9, 2017 17:29
-
-
Save dksheffield/8ead7efa7cc63059a702214bf0975298 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getCognitoCreds() { | |
console.log("starting function getCognitoCreds"); | |
var cognitoUser = cognitoFactory.getCognitoUser(); | |
cognitoUser.getSession(function(err, session) { | |
if (err) { | |
console.log(err, err.stack); | |
console.log("error getting the session"); | |
} else { | |
if (session.isValid() === false) { | |
console.log("session is not valid"); | |
} else { | |
console.log("session is valid"); | |
console.log(session.getIdToken().getJwtToken()); | |
console.log(AWS.config.credentials); | |
AWS.config.region = 'us-east-1'; | |
AWS.config.credentials = new AWS.CognitoIdentityCredentials({ | |
IdentityPoolId : 'us-east-1:7a697caa-e384-43c1-95fb-00c202418473', // your identity pool id here | |
Logins : { | |
'cognito-idp.us-east-1.amazonaws.com/us-east-1_e6xaq4Ewi' : session.getIdToken().getJwtToken() | |
} | |
}); | |
AWS.config.credentials.get(); | |
var cognitosync = new AWS.CognitoSync(); | |
var params = { | |
IdentityPoolId: 'us-east-1:7a697caa-e384-43c1-95fb-00c202418473' /* required */ | |
}; | |
cognitosync.describeIdentityPoolUsage(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
console.log(AWS.config.credentials); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment