[object Object] Icon

Learn how to create, start, manage and modify Encodings

[object Object] Icon

Learn how to create, start, manage and modify Players

[object Object] Icon

Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Wed Mar 09 2022

Player - Third Party Licensing

What is Third Party Licensing?Link Icon

The ThirdParty Licensing feature allows you to internally take control of Allowing or Denying the use of your Player Key. Normally the Bitmovin Players will validate a License call against a given License Key by comparing the requesting Domain(web), App Package(Android), Bundle ID(iOS), or Channel ID(Roku) against what you have Allow-Listed inside of your Bitmovin Dashboard. However, with Third Party Licensing we pass that control back to you. This may be useful scenarios such as:

  • Allowing Partners to embed your content on their site or app
  • Real time control and logging of your Player Licensing requests

CompatibilityLink Icon

Third Party Licensing is applied to a specific License Key which can be used by our Web, Android, iOS, and Roku Players.

How Does It Work?Link Icon

The 3rd Party Licensing workflow consists of the player first making the license request to our Licensing platform. Then the Bitmovin Licensing Platform passes that license request to the HTTPS endpoint that you specify in the Bitmovin Dashboard for your License. Your endpoint must accept a POST method call which contains a pre-defined JSON payload structure shown in the next section and then Accept or Deny the request based on the HTTP response we get from the POST method.

Data Passed To Your License Server:

The licensing HTTPS POST call will contain the following JSON Payload. There are 3 standard fields - domain, key, and version included in all requests along with an optional customData field.

  • domain - String containing the origin Domain, Package Name, Bundle Identifier, or Channel ID
  • key - String containing the License Key. This may be useful if you use the same endpoint for multiple Keys enabled with 3rd Party Licensing
  • version - String containing the Player version.
  • customData - Optional JSON Object containing key/value pairs which can contain arbitrary data. This data is set by calling the PlayerApi.setAuthentication method. NOTE: This field only applies to our HTML5-based Web Player.

Your licensing endpoint's Allow/Deny logic can you use any combination of the above data fields to determine whether or not to Allow licensing request. For example, if you want to enable Partner content by simply checking the domain you could just validate against the domain field.

For our HTML5 Player, we also allow you can enable more complex checks by requiring some arbitrary data(like a thirdPartyKey for example) to be passed in the customData field.

2 "customData": {
3 "param2": "data2",
4 "thirdPartyKey": "key1"
5 },
6 "domain": "dummydomain.com",
7 "key": "your_player_licensekey",
8 "version": "player_version"

Endpoint Responses:

Your licensing server needs to respond with either a 2xx code, 4xx code, or 5xx code as described below You can also return arbitrary customData in the response as well that will be passed to the client.

  • HTTP code 2xx -> Allow License
  • HTTP code 4xx -> Deny License
  • HTTP code 5xxx -> Allow/Deny based on configuration in your Bitmovin Dashboard

Timeout -> Response Timeout and Default Action based on configuration in your Bitmovin Dashboard.

Response codes 2xx will explicitly Allow while response codes 4xx will explicitly Deny. You can also set the default behavior for Internal Server Error codes 5xx as well as the default behavior if no response is given within your configured timeout.

Third Party Licensing is controlled at the Player Key level, so once enabled, ALL requests for a given key will be routed to the endpoint that you provided. If you are using 3rd Party Licensing to enable Partners to use your player/content, It is good practice to create secondary Player licenses to be used along with this licensing strategy to isolate Partner licensing from your own Production Player licensing.

Let’s Setup An Example Third Party License ServerLink Icon

This tutorial will be based on the supplemental sample content hosted in our Github repos here - https://github.com/bitmovin/licensing-demo

Creating The Server:

You can host your Licensing endpoint however you want - For example, a Java Servlet, AWS API Gateway + Lambda, NodeJS server, etc… For this example we will setup a simple Java Servlet that will look for an arbitrary key called thirdPartyKey to passed as a key/value in the customData field. The servlet will return a 200 if a valid thirdPartyKey is provided and will return a 400 code if not. In case of an Exception being raised the servlet will return a 500 code. In this example our Servlet will also return a customData JSON payload via Key/Value pairs.

1import com.google.gson.Gson;
2import com.google.gson.GsonBuilder;
3import javax.servlet.ServletException;
4import javax.servlet.http.HttpServlet;
5import javax.servlet.http.HttpServletRequest;
6import javax.servlet.http.HttpServletResponse;
7import java.io.IOException;
8import java.util.HashMap;
9import java.util.Map;
10public class LicenseServerServlet extends HttpServlet {
11 private final Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
12 @Override
13 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
14 LicenseRequest licenseRequest;
15 boolean allowLicense;
16 Map<Object, Object> customData = new HashMap<Object, Object>();
17 try {
18 licenseRequest = gson.fromJson(request.getReader(), LicenseRequest.class);
19 String thirdPartyKey = (String) licenseRequest.getCustomData().get("thirdPartyKey");
20 if (thirdPartyKey == null || !getLicenses().containsKey(thirdPartyKey)) {
21 customData.put("msg", "No valid thirdPartyKey provided");
22 sendDenyResponse(response, customData);
23 return;
24 }
25 allowLicense = getLicenses().get(thirdPartyKey);
26 if (!allowLicense) {
27 customData.put("msg", "thirdPartyKey: " + thirdPartyKey + " not allowed");
28 sendDenyResponse(response, customData);
29 return;
30 }
31 customData.put("domain", licenseRequest.getDomain());
32 sendAllowResponse(response, customData);
33 } catch (Exception e) {
34 customData = new HashMap<Object, Object>();
35 customData.put("msg", "Internal Server Error");
36 sendErrorResponse(response, customData, e.getMessage());
37 }
38 }
39 private void sendAllowResponse(HttpServletResponse response, Map<Object, Object> customData) throws IOException {
40 customData.put("message", "thirdPartyKey was approved.");
41 response.setStatus(200);
42 response.setContentType("application/json");
43 response.getWriter().write(gson.toJson(customData));
44 }
45 private void sendDenyResponse(HttpServletResponse response, Map<Object, Object> customData) throws IOException {
46 customData.put("message", "thirdPartyKey was denied.");
47 response.setStatus(400);
48 response.setContentType("application/json");
49 response.getWriter().write(gson.toJson(customData));
50 }
51 private void sendErrorResponse(HttpServletResponse response, Map<Object, Object> customData, String error) throws IOException {
52 customData.put("message", error);
53 response.setStatus(500);
54 response.setContentType("application/json");
55 response.getWriter().write(gson.toJson(customData));
56 }
57 private Map<String, Boolean> getLicenses() {
58 Map<String, Boolean> licenses = new HashMap<String, Boolean>();
59 licenses.put("12345", true);
60 licenses.put("67890", false);
61 return licenses;
62 }
64class LicenseRequest {
65 String domain;
66 String key;
67 String version;
68 Map<Object, Object> customData;
69 Map<Object, Object> getCustomData() {
70 return this.customData;
71 }
72 String getDomain() {
73 return this.domain;
74 }
75 String getKey() {
76 return this.key;
77 }
78 String getVersion() {
79 return this.version;
80 }

Now all you need to is to do is Host this Java Servlet.

NOTE: It's important to consider your average and peak player usage when hosting your Third Party Licensing endpoint and plan your capacity/redundancy/availability of your hosting accordingly. It is also important to consider how you want Bitmovin's License platform to handle both timeouts and server errors(5xx responses) from your endpoint - This is configurable and shown in the next section.

Enabling Third Party Licensing In The Bitmovin Dashboard:

Let's head over to the Bitmovin Dashboard to configure our Player License for Third Party Licensing. Once logged into your Dashboard, Select PLAYER -> Licenses from the left-hand menu and Select the License you want to enable.

  1. In the Third Party Licensing modal, enter your hosted License API endpoint into the Server Url input.
  2. Set your response timeout in milliseconds - Maximum of 2000 milliseconds
  3. Set your Default (Allow or Deny) for Error Action (5xx server response)
  4. Set your Default (Allow or Deny) for Timeout. 3rdPartyLicensing_a
  5. Lastly, click the Enable Button. 3rdPartyLicensing_B

Your License is now enabled for Third Party Licensing and ALL licensing requests for the given Key will be routed through this flow.

Player Configuration:

To round-off our above example, let’s configure a Bitmovin Web Player example that will set the example thirdPartyKey field that our sample Servlet expects.

1let playerConfig = {
2 key: "<Player License>",
4let source = {
5 hls: '...',
7let player = new bitmovin.player.Player(document.getElementById("player"), playerConfig);
9 thirdPartyKey: '12345'
12player.load(source).then(() => {
13 console.log('Source loaded successful');

Give us feedback