Minimal initialization of pixel streaming without node js server
Calling Token Generating API in the front-end exposes your Streaming API Key. Although it can’t be used to delete your apps or replace them with different apps, someone can misuse it to stream your apps without your permission. In such cases Eagle 3D Streaming will not be responsible. To avoid such incident we suggest calling the Token Generating API from Back-end. And passing that token to Front-end by server side rendering technique.
You can find the same code here: https://github.com/e3ds/full-html-control/tree/html/insecure
First, use the following command to clone the repository branch:
git clone -b html/insecure --single-branch https://github.com/e3ds/full-html-control
Â
After cloning, open postLoadScripts.js. Now update apiKey, domain, tokenExpiryDuration, clientUserName, app, config with your data.
window.onload = async function(){
const apiKey= "your streaming api key";//collect your streaming api key from here https://account.eagle3dstreaming.com/streaming-api-keys-management
const domain= "connector.eagle3dstreaming.com";
const tokenExpiryDuration= 60000;
const clientUserName= "your username";
const app= "your app name";
const config= "your configuration name";
fetch(
"https://token.eaglepixelstreaming.com/api/v1/token/create",
{
method: "POST",
body: JSON.stringify({
"object": {
"core": {
"domain": domain,
"userName": clientUserName,
"appName": app,
"configurationName": config
},
"expiry": tokenExpiryDuration,
"configurationToOverride": {}
},
"client": clientUserName
}),
headers: {
"Authorization": "Auth " + apiKey,
"Content-Type": "application/json"
}
}
).then(res=> res.json())
.then(data=> e3ds_controller.main(data.token, clientUserName))
.catch(error=> console.error(error));
}
File: postLoadScripts.js
After that open index.html in your browser. You can modify the index.html and postLoadScripts.js to customize the webpage according to your needs.
Useful Global Functions:
See this document for the useful Global Functions.