I have JsonWebKeys(JWK) for id_token and access_token. Then I got my id_token, from /token url. How to validate this JWT id_token using JWK in C#.
Needless to say I have tried almost everything but(IdenityModels.Jwt, etc) but JwtSecurityTokenHandler does not take JsonWebKey. I am using RS512 as signing algorithm.
I just implemented this myself for Google IdToken validation as:
Where
keyProvideris a:RSAetc. is justSystem.Security.Cryptography, whileBase64UrlEncoderis fromSystem.IdentityModel(but easy enough to do yourself)Unfortunately, it doesn't look like the other
kty/algvalues are as easy to support, e.g. there's noECDsa.ImportParameters(), it wants a genericCngKeyfrombyte[], so someone doing a generic .NET JWK library would have to pack thex,yparams themselves, presumably.