private static bool ValidateToken(string token, out string username, out ClaimsIdentity identity) { try { username = null; var simplePrinciple = JwtManager.GetPrincipal(token); if (simplePrinciple == null) { throw new Exception(JwtManager.ErrorMessages.IDX00000); } identity = JwtManager.CreateIdentity(simplePrinciple); if (identity == null) { throw new Exception(JwtManager.ErrorMessages.IDX00000); } if (!identity.IsAuthenticated) { throw new Exception(JwtManager.ErrorMessages.IDX00000); } var usernameClaim = identity.FindFirst(ClaimTypes.Name); username = usernameClaim?.Value; if (string.IsNullOrEmpty(username)) { throw new Exception(JwtManager.ErrorMessages.IDX00000); } return(true); } catch (Exception ex) { throw ex; } }