using Microsoft.IdentityModel.Tokens;
public static void Main()
var result = VerifyTokenWithAsymmetricKey(token);
Console.WriteLine(result);
public static bool VerifyTokenWithAsymmetricKey(string token)
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
if (string.IsNullOrEmpty(token))
var securityKey = Convert.FromBase64String("");
System.Security.Cryptography.RSA rsa = System.Security.Cryptography.RSA.Create();
rsa.ImportRSAPublicKey(securityKey, out _);
var vParam = new TokenValidationParameters
ValidateAudience = false,
ValidateIssuerSigningKey = true,
ValidIssuer = "user.authority",
IssuerSigningKey = new RsaSecurityKey(rsa)
var jsth = new Microsoft.IdentityModel.JsonWebTokens.JsonWebTokenHandler();
if (jsth.CanReadToken(token))
var result = jsth.ValidateToken(token, vParam);