using System; using System.Collections.Generic; using JWT; namespace HelloWorld { class Hello { static void Main() { var payload = new { iss = "ACxxx", exp = ConvertToUnixTimestamp(DateTime.UtcNow.AddSeconds(3600)), version = "v1", friendly_name = "WKxxx", account_sid = "ACxxx", workspace_sid = "WSxxx", worker_sid = "WKxxx", channel = "WKxxx", policies = new Dictionary[] { new Dictionary { { "url", "https://event-bridge.twilio.com/v1/wschannels/ACxxx/WKxxx"}, { "method", "GET"}, { "allow", true} }, new Dictionary { { "url", "https://event-bridge.twilio.com/v1/wschannels/ACxxx/WKxxx"}, { "method", "POST"}, { "allow", true} }, new Dictionary { { "url", "https://taskrouter.twilio.com/v1/Workspaces/WSxxx/Workers/WKxxx"}, { "method", "GET"}, { "allow", true} }, new Dictionary { { "url", "https://taskrouter.twilio.com/v1/Workspaces/WSxxx/Workers/WKxxx"}, { "method", "POST"}, { "allow", true}, { "query_filter", new {}}, { "post_filter", new { ActivitySid = new { required = true } }} }, new Dictionary { { "url", "https://taskrouter.twilio.com/v1/Workspaces/WSxxx/Tasks/**"}, { "method", "GET"}, { "allow", true} }, new Dictionary { { "url", "https://taskrouter.twilio.com/v1/Workspaces/WSxxx/Tasks/**"}, { "method", "POST"}, { "allow", true} } } }; Console.WriteLine(JsonWebToken.Encode(payload, "authToken", JwtHashAlgorithm.HS256)); } static int ConvertToUnixTimestamp(DateTime date) { DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); TimeSpan diff = date - origin; return (int)Math.Floor(diff.TotalSeconds); } } }