示例#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;
        }
        public string Generate(string role)
        {
            var capability = new TwilioCapability(_credentials.AccountSid, _credentials.AuthToken);
            capability.AllowClientOutgoing(_credentials.TwiMlApplicationSid);
            capability.AllowClientIncoming(role);

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

            ViewBag.token = capability.GenerateToken();

            return View();
        }
示例#4
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();
        }
  // 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");
  }
        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);
        }
示例#7
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);
 }