const twilio = require('twilio');

const accountSid = 'AC19a174c9ffc54c60569d2d0585ffc385';
const apiKeySid = 'SK7bc4c94d1c941c4c1a4a8177e389089d';
const apiKeySecret = 'tnr6Pmzs8FajEULuotEHfGRVlqZxOifi';
const twimlAppSid = 'AP607d1cf0ff4423a8728b3bb1b0f9b2c0';

const AccessToken = twilio.jwt.AccessToken;
const VoiceGrant = AccessToken.VoiceGrant;

const voiceGrant = new VoiceGrant({
    outgoingApplicationSid: twimlAppSid,
    incomingAllow: true
});

const token = new AccessToken(
    accountSid,
    apiKeySid,
    apiKeySecret,
    { identity: 'teste', ttl: 3600 }
);

token.addGrant(voiceGrant);

console.log('=== TOKEN GERADO ===');
console.log(token.toJwt());
console.log('==================');