内容目录
When directly using the API to get a Claim, the correctness of the Token's key is not checked.
var jwt = jwtSecurityTokenHandler.ReadJwtToken(token);
If you want to check the Token at the same time, you can use the following:
// Check the key
ClaimsPrincipal claimsPrincipal = jwtSecurityTokenHandler.ValidateToken(token, new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = SecurityKey,
ValidateIssuer = false,
ValidateAudience = false,
ClockSkew = TimeSpan.Zero
}, out SecurityToken securityToken);
文章评论