You can use TVSDK to send arbitrary data in cookie headers for session management, gate access, and so on.
Here is a example with some type of authentication when making requests to the key server:
To work with cookies:
Use the cookieHeaders
property in NetworkConfiguration
to set a cookie. The cookieHeaders
property is a Metadata object, and you can add key value pairs to this object to be included in the cookie header.
For example:
var metadata:Metadata = new Metadata();
metadata.setValue(“val1”, “12345”);
metadata.setValue(“val2”, “abcd”);
networkConfiguration.cookieHeaders = metadata;
By default, cookie headers are sent only with key requests. To send cookie headers with all requests, set the NetworkConfiguration
property useCookieHeadersForAllRequests
to true.
To ensure that NetworkConfiguration
works, set it as metadata:
var networkConfiguration:NetworkConfiguration = new NetworkConfiguration();
networkConfiguration.forceNativeNetworking = true;
var resourceMetadata:Metadata = new Metadata();
resourceMetadata.setMetadata(DefaultMetadataKeys.NETWORK_CONFIGURATION_KEY,
networkConfiguration);
Provide the metadata from the previous step when you create a MediaResource
.
For example, if you use the createFromURL
method, enter the following information:
var resource:MediaResource = MediaResource.createFromURL(url, resourceMetadata);