Open TLKG opened 2 years ago
@TLKG Was this fixed? If yes, how?
@elitan Following works locally
async function getMSPublicKey(misc)
{
var vurl = "https://login.microsoftonline.com/" + misc.tenantId + "/v2.0/.well-known/openid-configuration";
const x1 = await fetch(vurl);
const x2 = await x1.json();
const x3 = await fetch(x2.jwks_uri);
const k = await x3.json();
return pkey = k.keys.find( k => k.kid === misc.kid).x5c[0];
}
var publickey = "-----BEGIN CERTIFICATE-----\n" + await getMSPublicKey(vmisc) + "\n-----END CERTIFICATE-----";
var payload = jwt.verify(theToken, publickey, { algorithms: ['RS256'] });
After deployed to AZ got "JsonWebTokenError: invalid algorithm".
Thanks. The issue I had was an incorrect key string. It was solved on my end. Thanks.
Should this issue get closed then?
try this:
async function getMSPublicKey(misc) { var vurl = "https://login.microsoftonline.com/" + misc.tenantId + "/v2.0/.well-known/openid-configuration"; const x1 = await fetch(vurl); const x2 = await x1.json(); const x3 = await fetch(x2.jwks_uri); const k = await x3.json(); return pkey = k.keys.find( k => k.kid === misc.kid).x5c[0]; } var publickey = "-----BEGIN CERTIFICATE-----\n" + await getMSPublicKey(vmisc) + "\n-----END CERTIFICATE-----\n"; var payload = jwt.verify(theToken, publickey, { algorithms: 'RS256' });
Yeah in my case using a different library it was essentially a copy & paste error with the key
Description
Token validated ok at jwt.io. Received error with
.verify
Error:
Reproduction
Environment