Authentication & SSO
Implementing Authentication and Single Sign-On (SSO) in Cinema8
By default, Cinema8 videos play anonymously across all platforms. In this case, user interactions are tracked as anonymous, and all data collected by the system will be tagged as anonymous.
To track specific users who have already signed in to one of your systems (such as an intranet, extranet, mobile app, or LMS system), Cinema8's Data API can be used to generate an "on behalf of" authentication token for these users.
The user can utilize the "Login As with Username" method in the C8 Data API. After exposing this API and generating an "on behalf of" token for your users, you can pass this token to any web service call or use it with the JS API to track signed-in users.
Method: POST
URL: https://cinema8.com/api/v1/authenticate/loginAsWithUsername/bearer
Header: Content-Type: application/x-www-form-urlencoded
Payload:
token: XXX (This is the admin token generated from Cinema8 Token Console)
username: account-name\username
Here, you need to send the username information along with your account name to the service, as shown in the example: accountname\[username].
The API will return a 200 status code with the generated auth token. This token is valid for 6 hours, after which it becomes invalid. To continue tracking users, a new token must be generated. If desired, you can store the tokens in a 6-hour expiration map and use the token from this map for at least 6 hours.
If the user is not found in the system, a 401 status code will be returned, indicating that there is no user with the provided [user.name]. In such cases, the user can create the account before attempting to generate a token for unregistered users. Refer to the Cinema8 Data API to register users in the system.
A sample usage of the "on behalf of" token in the player:
// Setup
var player = new Cinema8Player("#video", {
id: "YVX3wMX4",
style: "position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; width: 100%; height: 100%; border: 0;",
authToken: "751963c10652935de6b94670de98833c430dc83c", // This is the token generated from the loginAsWithUsername API method
onready: function(){
console.log("onready fired");
},
onplay: function(){
console.log("onplay fired");
},
onpause: function(){
console.log("onpause fired");
},
onprogress: function(){
console.log("onprogress fired");
},
onend: function(){
console.log("onend fired");
}
});