Example #1
0
        public async Task <HttpResponseMessage> GetTaskRouterWorkspaceToken()
        {
            var capability = new TaskRouterWorkspaceCapability(settings.Account.Sid, settings.AuthToken, settings.TaskRouter.Workspace.Sid);

            capability.AllowFetchSubresources();
            capability.AllowUpdatesSubresources();
            capability.AllowDeleteSubresources();

            var response = new ApiResponse <TwilioToken>(new TwilioToken {
                Identity = UserIdentityID,
                Token    = capability.GenerateToken()
            });

            return(SendHttpResponse(response));
        }
    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";

        TaskRouterWorkspaceCapability capability = new TaskRouterWorkspaceCapability(AccountSid, AuthToken, WorkspaceSid);

        capability.AllowFetchSubresources();
        capability.AllowUpdatesSubresources();
        capability.AllowDeleteSubresources();
        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
    }