Reputation: 2300
I have installed Nuget package of "JSON Web Token Handler For the Microsoft .Net Framework 4.5" (link:- http://www.nuget.org/packages/System.IdentityModel.Tokens.Jwt/) for visual studio 2012. But it doesn't contains a definition for "X509SecurityToken". Which cause to show errors in following method...
private static void ValidateToken(string Token)
{
var tokenHandler = new JwtSecurityTokenHandler();
var validationParameters = new TokenValidationParameters()
{
ValidAudience = "<some url>",
IssuerSigningTokens = new List<X509SecurityToken>() { new X509SecurityToken(
X509
.LocalMachine
.My
.Thumbprint
.Find("112233445566xxyy", false)
.First()) },
ValidIssuer = "https://my-issuer.com/trust/issuer",
CertificateValidator = X509CertificateValidator.None,
RequireExpirationTime = true
};
try
{
SecurityToken validatedToken;
var principal = tokenHandler.ValidateToken(Token, validationParameters, out validatedToken);
}
catch (Exception e)
{
Console.WriteLine("{0}\n {1}", e.Message, e.StackTrace);
}
Console.WriteLine();
}
If anyone can provide any help or even hints I would greatly appreciated,
Thanks for helping, Kushan Randima.
Upvotes: 2
Views: 1289