aws-cognito-angular-quickstart
aws-cognito-angular-quickstart copied to clipboard
Unable to get temporary credentials
Hi,
I implemented your code in my angular project. I am able to fetch tokenID from AWS Cognito after verification but when I see credentials, it shows
accessKeyId:undefined data:null expireTime:null expired:true
I implemented, login, signup from your project. After successful login I am directly redirecting it to JWT. It displays the tokens. But When I tried printing the CognitoIdentityCredentials object it shows nothing.
I have done this in JWT callbackWithParam function:
AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: environment.identityPoolId, Logins: { 'cognito-idp.{{region}}.amazonaws.com/{{userpoolid}}' : idToken } });
Any idea what I might be doing wrong?
Regards, Shorabh
AWS.config.credentials is a magic wrapper over credentials, and its asynchronous operation to get temporary keys.
Try .get() or .refresh() methods on credentials object.
You can create promise:
AWS.config.credentials.get((err) => {
if (err) {
rejection(err)
} else {
resolve(AWS.config.credentials)
}
})
})
and then use it getCredentials.then(creds=> doSomething(creds))