Ooyala Player Token View
You can use the following code sample to understand how to add token authentication to a player experience.
The code sample includes multiple client web pages or views illustrating each feature and a seventh code sample that shows all the features working in combination. To implement each client page, you will need all the standard elements that you normally use, such as your API Key and pcode (for details, see Your API Credentials), and so forth.
Where to Find the Code
To explore this code sample view in GitHub, go tohttps://github.com/ooyala/code-samples/blob/master/application/views/Secure_XDR_GoogleIMA/token.php.
Ooyala Player Token Client Code
The token.php file implements Ooyala Player Token authentication content protection. In this Player Token sample, we use the following Player V3 APIs and parameters.
- OO.ready() - This function indicates that the script has loaded, initialized completely, and that the player is ready for playback.
- OO.Player.create() - This function creates a new message bus, creates any registered modules, and connects registered modules to the message bus. In the sample, you should note that OO.Player.create is used with embedToken in the hash with the embed token url as part of the key value pair.
- platform - This parameter is used to control selection of HTML5 or Flash playback. In the sample, it is set to Flash as the priority choice for playback.
Implementing the Player Token Sample
- Manually set the Require Ooyala Player Token checkbox in Backlot. See “Setting the Ooyala Player Token.”
- Craft an authorization request using the URL token request template. See Ooyala Player Token.
- Create the trigger to request authorization and a token from the Ooyala authorization server, using the token request. See Complete Web Example: Authorize Playback and Obtain a Token.
- Generate a computed signature. You need to generate signature using an http method.
You can use the PHP SDK or Ruby SDK to do this. The included PHP SDK has a mechanism to
generate the signature needed by the Ooyala Player Token. (See Ooyala Player Token). When you generate the
signature, you will have two parameters:
- a query parameter and
- an HTTP method. For the Ooyala Player Token, you need to use a GET request for the http method.
- Assemble the request and concatenate the results.