Wowza Community

Error using Vod Streaming with token

Hello,

I use tokens in vod streaming. But when I test the resulting url address it gives 403 Forbidden error. Can you help me?

Version: 4.8.0

Example code I wrote in Node.js and the setting screenshot I made in wowza panel:

var crypto = require(‘crypto’);

var express = require(‘express’);

var contentURL = ‘http://192.168.1.1:1935/vod/sample.mp4/playlist.m3u8

var sharedSecret = ‘xxxxxxxxxx’;

var contentPath = ‘/vod/sample.mp4’;

var customSecureTokenPrefix = ‘myTokenPrefix’;

var CustomParameter = ‘abcdef’;

const date = new Date().valueOf()

var starttime = date;

var endtime = date + 12000;

var toHash = contentPath + ‘?’ +

sharedSecret + ‘&’ +

customSecureTokenPrefix + ‘CustomParameter=’ + CustomParameter + ‘&’ +

customSecureTokenPrefix + ‘endtime=’ + endtime + ‘&’ +

customSecureTokenPrefix + ‘starttime=’ + starttime;

console.log("string for hash : " + toHash);

var hash = crypto.createHash(‘sha256’).

update(toHash, “utf8”).

digest(‘base64’);

hash = hash.replace(///g, ‘_’);

hash = hash.replace(/+/g, ‘-’);

var hlsURL = 'http://192.168.1.1:1935/vod/sample.mp4/playlist.m3u8?’ +

customSecureTokenPrefix + ‘starttime=’ + starttime + ‘&’ +

customSecureTokenPrefix + ‘endTime=’ + endtime + ‘&’ +

customSecureTokenPrefix + ‘CustomParameter=’ + CustomParameter + ‘&’ +

‘myTokenPrefixhash=’ + hash;

console.log("url for hls : " + hlsURL)

string for hash : string for hash : /vod/sample.mp4?xxxxxxxxxx&myTokenPrefixCustomParameter=abcdef&myTokenPrefixendtime=1586533227613&myTokenPrefixstarttime=1586533215613

url for hls : http://192.168.116.1:1935/vod/sample.mp4/playlist.m3u8?myTokenPrefixstarttime=1586533215613&myTokenPrefixendTime=1586533227613&myTokenPrefixCustomParameter=abcdef&myTokenPrefixhash=sFKHqXwp8yY4PqOcJhFChAvCEjmyhpgfN2nDo41xrp8=

Thank you.

Please edit your post and screenshot to remove shared secrets. You do not want that information public!

Take a look at this post with a PHP code example - https://www.wowza.com/community/questions/7786/securetoken-protection-in-wowza-streaming-enginehl.html