Authentication & SSO

In Default Cinema8 Videos play as anonymous in all platfoms.In this case you can track your users anonymously and all interactions collected by the systems will be tagged as anonymous.

To track certain users who has already signed in to one of your systems (This can be any intranet , extranet , mobile app or LMS systems) ,you can use Cinema8 Data Apis to generate an "on behalf of" auth token for your users.

You can use the "Login As with Username" method in C8 Data Api.After exposing this api and generated an "on behalf of" token for your users , pass this token to any web service call or use this token with JS API to track your 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 username information with your account name to the service.
as in the above example, accountname \ [username].

Api returns 200 status code with the generated auth token.Generated auth token is valid for 6 hour , after 6 hour the token will be invalid and you need to generate a new token for your users. If you want, you can simply put the tokens on a 6-hour expirable map.
You can usethe token from this map  in a valid way for at least 6 hours.

In case the user is not in the system, 401 status code will be returned. Indicates that there is no [user.name] user in the system, You can also create the user before trying to generate the token for unregistered users. See the Cinema8 Data API to register users on the system.

A sample usage of "on behalf of" token in 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 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");
    }
});