public JwtSecurityToken BuildToken(string sub, JsonWebTokenSettings jsonWebTokenSettings, string[] roles = null) { var claims = new List <Claim>(); claims.AddJti(); claims.AddSub(sub); if (roles != null && roles.Length > 0) { claims.AddRoles(roles); } return(GetJwtSecurityToken(claims, jsonWebTokenSettings)); }
private static JwtSecurityToken GetJwtSecurityToken(IEnumerable <Claim> claims, JsonWebTokenSettings jsonWebTokenSettings) { return(new JwtSecurityToken( jsonWebTokenSettings.Issuer, jsonWebTokenSettings.Audience, claims, DateTime.UtcNow, jsonWebTokenSettings.Expires, jsonWebTokenSettings.SigningCredentials )); }