コード例 #1
0
        public string GetToken(string clientId)
        {
            var capability = new TwilioCapability (AccountSid, AuthToken);
            
            /*
             A device configured with this token will receive incoming connections 
             anytime someone attempts to connect to "motoX"
             */
            capability.AllowClientIncoming(clientId);

            /*
             To make an outgoing connection from a device, you'll need to configure a capability token with the SID of a Twilio Application 
             so that Twilio will know what VoiceUrl to use to handle the connection.
             */
            capability.AllowClientOutgoing(ApplicationSid);

            /*
             If the token expires while the device has an active connection, the connection will not be terminated, 
             but the device will need to be re-initialized with a valid token before attempting 
             or receiving another connection.
             */
            /*
             * Note:- Note that the token generated is valid for 1 hour unless otherwise specified. 
             * To specify a different period of time, pass in the number of seconds 
             * as an integer parameter to generateToken() -- for example, for a token that expires after 5 minutes, 
             * call generateToken(300). The maximum allowed lifetime for a token is 24 hours.
             */
            var token = capability.GenerateToken();

            return token;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: kwhinnery/jumpstart
        public ActionResult Capability()
        {
            var capability = new TwilioCapability(Settings.AccountSid, Settings.AuthToken);
            capability.AllowClientOutgoing("AP784bd34e34fab9759b8e91d3ef3680b9");

            return Json(new { token = capability.GenerateToken() });
        }
コード例 #3
0
        public string Generate(string role)
        {
            var capability = new TwilioCapability(_credentials.AccountSid, _credentials.AuthToken);
            capability.AllowClientOutgoing(_credentials.TwiMlApplicationSid);
            capability.AllowClientIncoming(role);

            return capability.GenerateToken();
        }
コード例 #4
0
        public ActionResult Index()
        {
            var capability = new TwilioCapability(TwilioAccountSid, TwilioAuthToken);
            capability.AllowClientOutgoing(TwilioAppSid);
            capability.AllowClientIncoming(TwilioAppSid);

            ViewBag.token = capability.GenerateToken();

            return View();
        }
コード例 #5
0
        public ActionResult Agent(string id)
        {
            var capability = new TwilioCapability(Settings.AccountSid, Settings.AuthToken);

            capability.AllowClientIncoming(id);
            capability.AllowClientOutgoing(ApplicationSid);

            ViewBag.token = capability.GenerateToken();

            return View();
        }
コード例 #6
0
        void SetupTwilio()
        {
            // put your Twilio API credentials here
            string accountSid = "AC2cbe631411b305e102ac2e3ce2da0407";
            string authToken = "9093223b161f8d4a9a97577b5cddbc20";

            var capability = new TwilioCapability(accountSid, authToken);
            //capability.AllowClientIncoming;
            //capability.AllowClientOutgoing("APabe7650f654fc34655fc81ae71caa3ff");
            //string token = capability.GenerateToken();
        }
コード例 #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            var capability = new TwilioCapability(Settings.AccountSid, Settings.AuthToken);
            capability.AllowClientOutgoing("AP784bd34e34fab9759b8e91d3ef3680b9");

            string token = capability.GenerateToken();

            context.Response.Write(string.Format("{{ \"token\" : \"{0}\" }}", token));
        }
コード例 #8
0
  // GET: Token
  public ActionResult Index()
  {
    // put your Twilio API credentials here
    string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    string authToken = "your_auth_token";

    var capability = new TwilioCapability(accountSid, authToken);
    capability.AllowClientIncoming("jenny");
    string token = capability.GenerateToken();

    return Content(token, "application/jwt");
  }
コード例 #9
0
        public ActionResult Token()
        {
			var capabilities = new TwilioCapability (
				                   "REPLACE_WITH_YOUR_TWILIO_ACCOUNT_SID", 
				                   "REPLACE_WITH_YOUR_TWILIO_AUTH_TOKEN");

			capabilities.AllowClientIncoming ("REPLACE_WITH_A_CLIENT_NAME");
			capabilities.AllowClientOutgoing ("REPLACE_WITH_YOUR_TWIML_APPLICATION_SID");
			var token = capabilities.GenerateToken ();

            return Content (token);
        }
コード例 #10
0
 public string GetToken(Agent agent, int seconds = 60*60*24)
 {
     var twilioCapability = new TwilioCapability(accountSid, authToken);
     twilioCapability.AllowClientIncoming(agent.ClientID);
     return twilioCapability.GenerateToken(seconds);
 }