Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Amazon Cognito Refresh Token to get new token in javascript

When successfully logged in into the cognito user pool, I can retrieve access token and id token from the callback function as

onSuccess: function (result) {
    var accesstoken = result.getAccessToken().getJwtToken()
    var idToken = result.idToken.jwtToken
}

But how can I retrieve the refresh token? And how can I get a new token using this refresh token. I didnot find any clear answers.

like image 863
Manoj Acharya Avatar asked May 26 '26 00:05

Manoj Acharya


1 Answers

You can use result.getRefreshToken().getToken() for that. The success callback takes CognitoUserSession object i.e. result as a parameter which exposes getRefreshToken method to retrieve refresh token.

Refer this link for Cognito JavaScript SDK documentation -

https://github.com/aws/aws-amplify/tree/master/packages/amazon-cognito-identity-js

Not sure if I clearly understand your second question, but Use case 32 in above link might help you in dealing with it.

like image 82
Siddhesh Salgaonkar Avatar answered May 27 '26 12:05

Siddhesh Salgaonkar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!