public string ToJwt(string secret) { if (string.IsNullOrWhiteSpace(secret)) { throw new ArgumentNullException(nameof(secret), $"The {nameof(secret)} must be provided to encode the token"); } return(new JwtBuilder() .WithAlgorithm(new HMACSHA512Algorithm()) .WithSecret(secret) .AddClaim(Claims.Identity, Principal) .AddClaim(Claims.Expiry, Expiry.ToUnixTimeSeconds()) .AddClaim(Claims.Resources, Resources) .Encode()); }