Created
June 5, 2018 17:04
-
-
Save prasadjay/50f0698e367b46392ec8d15425e48346 to your computer and use it in GitHub Desktop.
Renew-Cognito-Tokens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renew() { | |
const RefreshToken = new AmazonCognitoIdentity.CognitoRefreshToken({RefreshToken: "your_refresh_token_from_a_previous_login"}); | |
const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData); | |
const userData = { | |
Username: "sample@gmail.com", | |
Pool: userPool | |
}; | |
const cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData); | |
cognitoUser.refreshSession(RefreshToken, (err, session) => { | |
if (err) { | |
console.log(err); | |
} else { | |
let retObj = { | |
"access_token": session.accessToken.jwtToken, | |
"id_token": session.idToken.jwtToken, | |
"refresh_token": session.refreshToken.token, | |
} | |
console.log(retObj); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment