0

Basically I'm backend developer of Laravel. I want to create accessToken for video call using Twilio, front-end is mobile app (Flutter) backend is Laravel.

Don't Panic
  • 13,965
  • 5
  • 32
  • 51

1 Answers1

3

Twilio developer evangelist here.

As mentioned in these docs, you can generate an access token

In PHP, that'd look like

<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\VideoGrant;
// Required for all Twilio access tokens
$twilioAccountSid = 'ACxxxxxxxxxxxx';
$twilioApiKey = 'SKxxxxxxxxxxxx';
$twilioApiSecret = 'xxxxxxxxxxxxxx';

// A unique identifier for this user
$identity = "alice";
// The specific Room we'll allow the user to access
$roomName = 'DailyStandup';

// Create access token, which we will serialize and send to the client
$token = new AccessToken($twilioAccountSid, $twilioApiKey, $twilioApiSecret, 3600, $identity);

// Create Video grant
$videoGrant = new VideoGrant();
$videoGrant->setRoom($roomName);

// Add grant to token
$token->addGrant($videoGrant);
// render token to string
echo $token->toJWT();

Depending on what your Twilio Video app looks like, you may be able to do something like what I did in JavaScript here with the Twilio CLI.

Let me know if this helps at all!

lizziepika
  • 3,231
  • 1
  • 14
  • 23