1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Securing videos with a unique key
This guide explains how to protect videos imported into an Infomaniak VOD service with a unique key.
Protecting a Video with a Unique Key
You have the option to protect all media in a folder by creating a token. This will be unique for each of your visitors and must be passed as a parameter to your media to limit its viewing. Only you will be able to generate the unique key required by each user to view the videos. This key therefore allows only individuals previously verified by you to be authorized.
This allows you to control access to the videos and only allow certain people, while others are denied. Useful in cases such as pay-per-view or limited broadcasts. However, please note that it is your responsibility to develop the integration into your existing system.
If the hash is not valid, accessing the video will return a "403 Forbidden" error page.
Enabling Restriction on Import Folder
When the password is set once for all at the destination folder level, all new media imports will automatically have this mode enabled when played. To configure this folder:
- Login to the Infomaniak Manager (manager.infomaniak.com) using a web browser like Brave or Edge.
- Click on the icon at the top right of the interface (or navigate via the left side menu, e.g., here).
- Select VOD/AOD (Streaming universe).
- Click on the name of the relevant object in the displayed table.
- Click on Media in the left side menu.
- Click on Media Management in the left side menu.
- Click on the icon to create a New Folder
- Give a name to the folder.
- Click the blue button to Create the folder.
- Click on Configuration
- Select the encoding rules for the imported videos and proceed to the next step.
- Configure the folder options in this second step and proceed to the next step.
- Enable restriction with a unique key.
- Click the blue button once the desired restrictions are configured
1. Create a VOD API Token
To access the VOD API, you must first authenticate with an application token. This step only needs to be done once. The application token will be common for all folders you wish to protect. To create this application token, read this guide and the documentation at https://developer.infomaniak.com/getting-started#authentication.
2. Create the Playback Token
This step must be done on your website/application, and this token must be unique, hence generated for each visitor.
It is therefore important that the page responsible for token generation does not have a cache, to ensure the uniqueness of the token.
POST https://api.vod2.infomaniak.com/api/pub/v1/channel/channel_id/share/share_id/token
channel_id
= 1227share_id
= the ID of your video
Example: https://api.vod2.infomaniak.com/res/embed/1jhvl2uqa5rdf.html
The list of parameters is available in the documentation at https://developer.infomaniak.com/docs/api/post/channel/share/token
3. Using the Unique Token on a Media
The token obtained in step 2 above will then be passed as a parameter to the media, it will be unique and therefore different for each visitor:
<iframe frameborder="0" width="720" height="360" src="https://api.vod2.infomaniak.com/res/embed/1jhvl2uqa5rdf.html?token=st=1637143497~exp=1637143797~acl=/hls/1jhvl2uq4dnra/1jhvl2uq4dnmd/*~hmac=914aa838bdba141ec85db74266b54278572a1353a49e8851e4fd096dc6372127" allowfullscreen></iframe>
Additional access restrictions can be enabled: password + GeoIP.