Forked from koladilip/aws-cognito-refresh-tokens-from-brower.js
Last active
December 18, 2019 15:02
-
-
Save joshuaquek/a396e5cf2da53c82ad2b7e5220b0df4c to your computer and use it in GitHub Desktop.
Code for refreshing AWS Cognito user pool tokens using refresh token from browser.
This file contains hidden or 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
Summary: Code for refreshing AWS Cognito user pool tokens using refresh token from browser. |
This file contains hidden or 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
fetch("https://cognito-idp.<cognito-user-pool-region>.amazonaws.com/", { | |
headers: { | |
"X-Amz-Target": "AWSCognitoIdentityProviderService.InitiateAuth", | |
"Content-Type": "application/x-amz-json-1.1", | |
}, | |
mode: 'cors', | |
cache: 'no-cache', | |
method: 'POST', | |
body: JSON.stringify({ | |
ClientId: "<cognito-user-pool-client-id>", | |
AuthFlow: 'REFRESH_TOKEN_AUTH', | |
AuthParameters: { | |
REFRESH_TOKEN: "<cognito-refresh-toke>", | |
//SECRET_HASH: "your_secret", // In case you have configured client secret | |
} | |
}), | |
}).then((res) => { | |
return res.json(); // this will give jwt id and access tokens | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment