Skip to main content

Generating OTP for offline use

Offline video is available with our Android SDK. You can allow your viewers to download an encrypted version of the video to their Android devices. This video can be made to expire after a certain time by specifying a rental duration. The access token in this case also need to specified to allow persistence of license.

This code below creates an OTP with permission to persist on viewer's device. The downloaded file will be valid for the 15 days from the time of setup.

{  "licenseRules": json_serialize({    "canPersist": true,    "rentalDuration": 15 * 24 * 3600,  })}

It is also possible to specify the time from which the license can be valid AFTER the first time use.

Create offline OTP#

The sample videoID is 1234567890 and the API Secret Key is a1b2c3d4e5. The rental duration is set to 15 days (1296000 seconds) in the following sample codes.

The sample code only passes the OTP licenseRules as parameter. It is possible to combine this with other OTP parameters

Note that the value of licenseRules is a string with serialized JSON and not a JSON object

curl -X POST \  https://dev.vdocipher.com/api/videos/1234567890/otp \  -H 'Accept: application/json' \  -H 'Authorization: Apisecret a1b2c3d4e5' \  -H 'Content-Type: application/json' \  -d '{  "licenseRules": "{\"canPersist\": true, \"rentalDuration\": 1296000}"}'