PlaybackGrant
The PlaybackGrant resource allows developers to generate a grant to initialize the Player SDK. The grant provides a playback token that the Player will use to connect to the livestream.
API Base URL
All URLs in the reference documentation use the following base URL:
https://media.twilio.com/v1
PlaybackGrant properties
Resource Properties in REST API format | |
---|---|
sid
|
The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for. |
url
|
The absolute URL of the resource. |
account_sid
|
The SID of the Account that created this resource. |
date_created
|
The date and time in GMT when the resource was created specified in ISO 8601 format. |
grant
|
The grant that authorizes the player sdk to connect to the livestream |
Create a PlaybackGrant
URL
# HTTP POST
https://media.twilio.com/v1/PlayerStreamers/{PlayerStreamerSID}/PlaybackGrant
Parameters
Parameters in REST API format | |
---|---|
sid
Path
|
The unique string generated to identify the PlayerStreamer resource associated with this PlaybackGrant |
ttl
Optional
|
The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds. |
access_control_allow_origin
Optional
|
The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain. |
Example: Create a PlaybackGrant
Example: Create a PlaybackGrant with a 60-second TTL
Example: Attach a PlaybackGrant to an Access Token
In order to attach a PlaybackGrant to an Access Token, you will first need to create a PlaybackGrant via the REST API. Once you have created the PlaybackGrant, you must wrap it in a PlaybackGrant object from Twilio's jwt
helper library to attach it to an Access Token. This code sample shows how to both create a PlaybackGrant via the API and then attach it to an Access Token.
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.