From 94dc4eea544ec028da5da4007614fafed9880e6e Mon Sep 17 00:00:00 2001 From: Kritarth Date: Wed, 17 Jun 2020 14:18:42 +0530 Subject: [PATCH] update jwt example --- examples/jwt.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/jwt.js b/examples/jwt.js index ec91e04..11f3539 100644 --- a/examples/jwt.js +++ b/examples/jwt.js @@ -7,6 +7,12 @@ var acctkn = new Plivo.AccessToken('{authId}', '{authToken}', '{endpointUsername 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}');