5) Validate the ID token. This is an important security measure to ensure the authenticity of the token and guard against any tampering.
To verify the signature of our ID tokens, we host a public JSON Web Key (JWK) here. For details on how to use our JWK in validating ID tokens, see How to validate an OpenID Connect ID token.
Alternatively rather than writing your own, you can use an existing library.
The website for JWT information https://jwt.io/ will list .net compatible libraries, click libraries at the top and change the filter paremter. Microsoft itself even provides one.
Where the library I use will grab the keys[0]->n (well the keys from the key file as a whole) from https://id.twitch.tv/oauth2/keys and then attempt to convert that to a PEM to then be used.
I don’t know what the .net equivalent is for this.