I am building an Angular2 application that will utilize Cognito User Pool sign-in. I am able to successfully authenticate a user; however, have been unable to get the access key, secret key, and session token for the authenticated user.
To my understanding, I should be able to call AWS.config.credentials.get( <callback> )
as shown below, but TypeScript complains that the get
method is not found (though I can see the method in type declarations for the aws-sdk module).
Any ideas?
// As part of authenticateUser - onSuccess callback...
var logins = {};
logins[`cognito-idp.${CognitoHelper.REGION}.amazonaws.com/${CognitoHelper.USER_POOL_ID}`] = session.getIdToken().getJwtToken();
// Add the user's token to the credential map
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: CognitoHelper.IDENTITY_POOL_ID,
Logins: logins
});
// Get access keys
AWS.config.credentials.get( (error) => { <-- .get method not found!
if (error) { // do something }
});