0
votes

I am setting a programmable voice chat token using the following codes:

    const accessToken = new AccessToken(config.accountSid, config.apiKey, config.apiSecret);
    accessToken.identity = user_uid;

      var grant = new VoiceGrant({
        outgoingApplicationSid: config.twimlAppSid,
        incomingAllow: false,
      });

    accessToken.addGrant(grant);

    return resolve(JSON.stringify({ token: accessToken.toJwt() }));

With the previous deprecated method: ClientCapability, I was able to assign an expiration time for the generated capability with ttl property:

    const capability = new ClientCapability({
      accountSid: config.accountSid,
      authToken: config.authToken,
      ttl: 300
    });

With the new AccessToken and VoiceGrant, is it still possible to set an expiration time manually? I did not find any relevant section in the documentation.

1

1 Answers

0
votes

I found out that we can passin an optional ttl setting when creating an access token:

const accessToken = new AccessToken(config.accountSid, config.apiKey, config.apiSecret, {ttl: 7200});

or

    accessToken.ttl = 7200;

It is specified in the Twilio source code.