Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Unable to get temporary credentials #132

Open
shorabhd opened this issue Mar 20, 2018 · 1 comment
Open

Unable to get temporary credentials #132

shorabhd opened this issue Mar 20, 2018 · 1 comment

Comments

@shorabhd
Copy link

shorabhd commented Mar 20, 2018

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

@mordka
Copy link

mordka commented Mar 29, 2018

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))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants