// reading tokens and checking them for user are separate, split for DRY if needed public JwtSecurityToken ReadToken(string token) { var tokenHandler = new JwtSecurityTokenHandler(); if (tokenHandler.CanReadToken(token)) { var res = tokenHandler.ValidateToken(token, _jwtSettings.GetTokenValidationParameters(), out var rawToken); var validatedToken = (JwtSecurityToken)rawToken; return(validatedToken); } return(null); }