I am trying out the log in function for the Cognito User Pool for my Web App. I was able to obtain the Token but I am not sure where to find the secret to decode it. I\'ve rea
Just want to summarize this topic with the snippet of code:
const jwkToPem = require('jwk-to-pem');
const requestify = require('requestify');
/**
* Get cognito's secret key
* @param {String} region
* @param {String} userPoolId
* @returns {Promise}
*/
function getPem(region, userPoolId) {
const jwkUrl = `https://cognito-idp.${region}.amazonaws.com/${userPoolId}/.well-known/jwks.json`;
return requestify.request(jwkUrl, { method: 'get', dataType: 'json'})
.then(res => res.getBody()['keys'].shift())
.then(jwk => jwkToPem(jwk))
;
}