Skip to content

Instantly share code, notes, and snippets.

@mdesanti
Created September 1, 2016 12:37
Show Gist options
  • Save mdesanti/bb1aa04a15e8acf08ba8ad0e6a42b3b4 to your computer and use it in GitHub Desktop.
Save mdesanti/bb1aa04a15e8acf08ba8ad0e6a42b3b4 to your computer and use it in GitHub Desktop.
console.log(cognitoUser)
AWS.config.region = 'us-east-1';
if (cognitoUser != null) {
cognitoUser.getSession(function(err, result) {
if (result) {
console.log('You are now logged in.');
// Add the User's Id Token to the Cognito credentials login map.
console.log(result.getIdToken().getJwtToken());
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'us-east-1:4a901632-401e-4ffd-bc73-c5272318a1a3',
Logins: {
'cognito-idp.us-east-1.amazonaws.com/us-east-1_tcZQYFXiy': result.getIdToken().getJwtToken()
}
});
}
});
}
AWS.config.credentials.get(function(err) {
if (!err) {
console.log({ accessKey: AWS.config.credentials.accessKeyId, secretKey: AWS.config.credentials.secretAccessKey, sessionToken: AWS.config.credentials.sesionToken })
var apigClient = apigClientFactory.newClient({
accessKey: AWS.config.credentials.accessKeyId,
secretKey: AWS.config.credentials.secretAccessKey
});
apigClient.paypalGet().then(function(result) { console.log(result) }).catch(function(result) { console.log(result) })
// apigClient.paypalOptions().then(function(result) { console.log(result) }).catch(function(result) { console.log(result) })
} else {
console.log(err);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment