Menu

Expand
Rate this page:

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
sid<VJ> Not PII

The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for.

url
url Not PII

The absolute URL of the resource.

account_sid
sid<AC> Not PII

The SID of the Account that created this resource.

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in ISO 8601 format.

grant
object Not PII

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
post sid<VJ> Not PII

The unique string generated to identify the PlayerStreamer resource associated with this PlaybackGrant

ttl
Optional
post integer Not PII

The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.

access_control_allow_origin
Optional
post string Not PII

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

Loading Code Sample...
        
        

        Create a PlaybackGrant

        Example: Create a PlaybackGrant with a 60-second TTL

        Loading Code Sample...
              
              

              Create a PlaybackGrant with 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.

              Loading Code Sample...
                    
                    

                    Attach a PlaybackGrant to an Access Token

                    Rate this page:

                    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.

                    Loading Code Sample...
                          
                          
                          

                          Thank you for your feedback!

                          Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

                          Sending your feedback...
                          🎉 Thank you for your feedback!
                          Something went wrong. Please try again.

                          Thanks for your feedback!

                          thanks-feedback-gif