How to use the twilio.Capability function in twilio

To help you get started, we’ve selected a few twilio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwilioDevEd / api-snippets / client / capability-token-2way / capability-token.2.x.js View on Github external
app.get('/token', function(req, res) {
  // put your Twilio API credentials here
  var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  var authToken = "your_auth_token";

  // put your Twilio Application Sid here
  var appSid = "APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  var capability = new twilio.Capability(accountSid, authToken);
  capability.allowClientOutgoing(appSid);
  capability.allowClientIncoming(req.body.ClientName);
  var token = capability.generate();

  res.set('Content-Type', 'application/jwt')
  res.send(token);
});
github TwilioDevEd / api-snippets / client / capability-token-incoming / capability-token.2.x.js View on Github external
app.get('/token', function(req, res) {
  // put your Twilio API credentials here
  var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  var authToken = "your_auth_token";

  var capability = new twilio.Capability(accountSid, authToken);
  capability.allowClientIncoming("jenny");
  var token = capability.generate();

  res.set('Content-Type', 'application/jwt')
  res.send(token);
});
github TwilioDevEd / api-snippets / client / capability-token-outgoing / capability-token.2.x.js View on Github external
app.get('/token', function(req, res) {
  // put your Twilio API credentials here
  var accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
  var authToken = "your_auth_token";

  // put your Twilio Application Sid here
  var appSid = "APXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";

  var capability = new twilio.Capability(accountSid, authToken);
  capability.allowClientOutgoing(appSid);
  var token = capability.generate();

  res.set('Content-Type', 'application/jwt')
  res.send(token);
});
github twilio / twilio-video.js / test / functional / endpoint.js View on Github external
function makeIncomingCapabilityToken(incomingClientName) {
  var capability = new twilio.Capability(ACCOUNT_SID, AUTH_TOKEN);
  capability.allowClientIncoming(incomingClientName);
  return capability.generate();
}
github twilio / twilio-video.js / test / unit / capabilitytoken.js View on Github external
function getCapabilityToken(incomingClientName, outgoingAppSid, outgoingParameters, errorCallback, successCallback) {
  var capability = new twilio.Capability(ACCOUNT_SID, AUTH_TOKEN);
  if (incomingClientName)
    capability.allowClientIncoming(incomingClientName);
  if (outgoingAppSid) {
    if (outgoingParameters)
      capability.allowClientOutgoing(outgoingAppSid, util.fromURLFormEncoded(outgoingParameters));
    else
      capability.allowClientOutgoing(outgoingAppSid);
  }
  var capabilityTokenString = capability.generate();
  try {
    var capabilityToken = new CapabilityToken(capabilityTokenString);
  } catch (e) {
    return errorCallback(e);
  }
  successCallback(capabilityToken);
}
github twilio / twilio-video.js / test / functional / endpoint.js View on Github external
function makeOutgoingCapabilityToken(outgoingParameters) {
  var capability = new twilio.Capability(ACCOUNT_SID, AUTH_TOKEN);
  capability.allowClientOutgoing(APP_SID, outgoingParameters || null);
  return capability.generate();
}
github drobtravels / universal-contact-center-be / functions / getTwilioTokens / src / index.js View on Github external
function getTwilioClientToken(email, credentials) {
  var capability = new twilio.Capability(credentials.accountSid, credentials.authToken)
  capability.allowClientIncoming(emailToClientName(email))
  capability.allowClientOutgoing(credentials.outgoingApplicationSid)
  return(capability.generate())
}
github crtr0 / twilio-webrtc-node / index.js View on Github external
response.end(twiml.toString());
    }
    else if (hash.pathname === '/random') {
      var client = new twilio.RestClient(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
      client.messages.list({'To': 'yyy'}, function(err, data) {
        random = data.messages[Math.floor(Math.random() * data.messages.length - 1)];
        var twiml = new twilio.TwimlResponse();
        twiml.dial({'callerId': 'yyy'}, function() {
          this.number(random.from);
        });
        response.writeHead(200, {'content-type': 'text/xml'});
        response.end(twiml.toString());        
      });
    }
    else if (hash.pathname === '/token') {
      var capability = new twilio.Capability(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);
      capability.allowClientOutgoing('APxxx');
      response.end(capability.generate());
    }
    else {
      file.serve(request, response);
    }
  }).resume();
}).listen(process.env.PORT || 3000);
github SamyPesse / betty / lib / twilio / index.js View on Github external
function createCapability(user) {
    var capability = new Twilio.Capability(config.twilio.sid, config.twilio.token);
    capability.allowClientOutgoing(config.twilio.app);
    capability.allowClientIncoming(user.username);
    return capability.generate();
}