private string GenerateToken(Account account, string ip) { UserIdentity identity = account.ToUserIdentity(ip); var claims = identity.GetClaims(); byte[] key = Convert.FromBase64String(this.Config.Secret); SymmetricSecurityKey securityKey = new(key); SecurityTokenDescriptor descriptor = new() { Subject = new ClaimsIdentity(claims), Expires = DateTime.UtcNow.AddSeconds(this.Config.RefreshTokenExpiration * 60), SigningCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256Signature) }; JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler(); JwtSecurityToken token = handler.CreateJwtSecurityToken(descriptor); return(handler.WriteToken(token)); }