Amplify-js: can I use this library in node to check the validity of the token

Created on 18 Jul 2018  Â·  6Comments  Â·  Source: aws-amplify/amplify-js

Can I use amplify-js to check the token's validity.

I've been looking at cognito-express but could I use this library instead?

Cognito question

Most helpful comment

Can you try

Auth.currentSession(session => {
    const payload = session.getIdToken().decodePayload();
    console.log('decode jwt token from cognito', payload);
})

All 6 comments

@dagda1 Amazon Cognito Federated Identities validates the token when you are invoking Auth.federatedSignIn on Amplify, then it returns credentials if token is valid or not.

thanks, but i am not using federated identities.

On Wed, 18 Jul 2018 at 22:59, elorzafe notifications@github.com wrote:

@dagda1 https://github.com/dagda1 Amazon Cognito Federated Identities
validates the token when you are invoking Auth.federatedSignIn on
Amplify, then it returns credentials if token is valid or not.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/aws-amplify/amplify-js/issues/1265#issuecomment-406087415,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAHOOOcyLzTVVJr4aEVGm8TQ5DlcC26Rks5uH6-lgaJpZM4VVTna
.

@dagda1 what do you mean by checking the token's validity?

@powerful23 yes, to decode the token and check the validity

Can you try

Auth.currentSession(session => {
    const payload = session.getIdToken().decodePayload();
    console.log('decode jwt token from cognito', payload);
})

Closing the issue. Feel free to reopen if you still have this issue.

Was this page helpful?
0 / 5 - 0 ratings