public void ShouldAllowFetchAll() { var token = cap.GenerateToken(); var payload = JsonWebToken.DecodeToObject(token, "foobar") as IDictionary <string, object>; var policies = payload["policies"] as System.Collections.IList; var defaultPoliciesCount = policies.Count; cap.AllowFetchSubresources(); token = cap.GenerateToken(); Assert.IsNotNullOrEmpty(token); payload = JsonWebToken.DecodeToObject(token, "foobar") as IDictionary <string, object>; policies = payload["policies"] as System.Collections.IList; Assert.AreEqual(defaultPoliciesCount + 1, policies.Count); var url = "https://taskrouter.twilio.com/v1/Workspaces/WS456/TaskQueues/WQ789/**"; var policy = policies[3] as IDictionary <string, object>; Assert.AreEqual(url, policy["url"]); Assert.AreEqual("GET", policy["method"]); Assert.IsTrue((bool)policy["allow"]); var queryFilter = policy["query_filter"] as IDictionary <string, object>; Assert.IsEmpty(queryFilter); var postFilter = policy["post_filter"] as IDictionary <string, object>; Assert.IsEmpty(postFilter); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string TaskQueueSid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; TaskRouterTaskQueueCapability capability = new TaskRouterTaskQueueCapability(AccountSid, AuthToken, WorkspaceSid, TaskQueueSid); capability.AllowFetchSubresources(); capability.AllowUpdates(); var token = capability.GenerateToken(); // By default, tokens are good for one hour. // Override this default timeout by specifiying a new value (in seconds). // For example, to generate a token good for 8 hours: token = capability.GenerateToken(28800); // 60 * 60 * 8 }