I have this class called ValidateToken, but I can not find the error because in the compilation everything is fine but when executing (in debug mode) the class sends me a message
Invalid syntax on line 1.
public bool validateToken(string TokenString)
{
bool result = false;
try
{
SecurityToken securityToken = new JwtSecurityToken(TokenString);
JwtSecurityTokenHandler securityTokenHandler = new JwtSecurityTokenHandler();
RSACryptoServiceProvider publicAndPrivate = new RSACryptoServiceProvider();
if (securityKey.ToString() == null)
return result;
publicAndPrivate.FromXmlString(securityKey.ToString());
TokenValidationParameters validationParameters = new TokenValidationParameters()
{
IssuerSigningKey = new RsaSecurityKey(publicAndPrivate)
};
ClaimsPrincipal claimsPrincipal = securityTokenHandler.ValidateToken(TokenString, validationParameters, out securityToken);
result = true;
}
catch (Exception e)
{
result = false;
}
return result;
}
TokenString is the token I send from the client to validate with the server
Any questions in the code will be attentive. Greetings in advance.