Untitled
unknown
plain_text
2 years ago
780 B
5
Indexable
exports.handler = function(context, event, callback) { const AccessToken = require('twilio').jwt.AccessToken; const VoiceGrant = AccessToken.VoiceGrant; const twilioAccountSid = context.ACCOUNT_SID; const twilioApiKey = context.API_KEY_SID; const twilioApiSecret = context.API_SECRET; const outgoingApplicationSid = context.APP_SID; const pushCredentialSid = context.PUSH_CREDENTIAL_SID; const identity = event.identity || 'alice'; const voiceGrant = new VoiceGrant({ outgoingApplicationSid: outgoingApplicationSid, pushCredentialSid: pushCredentialSid }); const token = new AccessToken(twilioAccountSid, twilioApiKey, twilioApiSecret, {ttl: 20157}); token.addGrant(voiceGrant); token.identity = identity; callback(null, token.toJwt()); };
Editor is loading...