mirror of
https://github.com/donl/plivo-node.git
synced 2026-05-25 22:07:10 -06:00
22 lines
939 B
JavaScript
22 lines
939 B
JavaScript
var Plivo = require('../dist/rest/client.js');
|
|
|
|
// token generation using from epoch and length in seconds
|
|
var acctkn = new Plivo.AccessToken('{authId}', '{authToken}', '{endpointUsername}', {validFrom: (new Date()).getTime()/1000, lifetime: 300}, '{uid}');
|
|
|
|
// voice (incoming, outgoing) grants
|
|
acctkn.addVoiceGrants(false, true);
|
|
console.log(acctkn.toJwt());
|
|
|
|
// token generation using from epoch and to epoch
|
|
acctkn = new Plivo.AccessToken('{authId}', '{authToken}', '{endpointUsername}', {validFrom: (new Date()).getTime()/1000, validTill: (new Date()).getTime()/1000 + 300}, '{uid}');
|
|
|
|
// voice (incoming, outgoing) grants
|
|
acctkn.addVoiceGrants(true, false);
|
|
console.log(acctkn.toJwt());
|
|
|
|
// token with validity of 24 hours starting now
|
|
acctkn = new Plivo.AccessToken('{authId}', '{authToken}', '{endpointUsername}', {}, '{uid}');
|
|
|
|
// voice (incoming, outgoing) grants
|
|
acctkn.addVoiceGrants(true, true);
|
|
console.log(acctkn.toJwt());
|