1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Secure videos with a unique key
This guide explains how to protect videos imported into a VOD service with a unique key.
Protect a video with a unique key
You have the possibility to protect all the media in a folder by creating a token. The latter will be unique for each of your visitors and must be passed as a parameter to your media to limit viewing. Only you will be able to generate the unique key, necessary for each user to watch the videos. This key therefore allows only the people previously verified by you to be authorized.
This allows you to control access to videos and only authorize certain people, while others are denied. Useful in cases such as pay-per-view
or limited broadcasts. However, please note that it is up to you to develop the integration with your existing system.
If the hash is not valid, access to the video will return an error page "403 forbidden
".
Enable restriction on the import folder
Once the password is set once and for all at the destination folder level, all new media imports will automatically include this mode for playback. To configure this folder:
- Click here to access the management of your product on the Manager Infomaniak (need help?).
- Click directly on the name assigned to the product in question.
- Click on Media in the left sidebar.
- Click on Media Management in the left sidebar.
- Click on the icon to create a New folder:
- Name the folder.
- Click on the blue button to Create the folder.
- Click on Configuration:
- Select the encoding rules for the videos that will be imported, then proceed to the next step.
- Configure the folder options in this second step, then proceed to the next step.
- Enable the unique key restriction.
- Click on the blue button once the desired restrictions have been configured:
1. Create a VOD API token
To access the VOD API, you must first authenticate using 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, refer to this other guide and then the documentation 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, so generated for each visitor.
It is therefore important that the page responsible for generating the token does not have a cache, in order to guarantee 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
= corresponds to your video's identifier
Example: https://api.vod2.infomaniak.com/res/embed/1jhvl2uqa5rdf.html
The list of parameters is available in the documentation https://developer.infomaniak.com/docs/api/post/channel/share/token
3. Using the unique token on a media
The token retrieved in step 2 above will 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>