About OIDC's ID Token Verification

To quote the documentation

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.