Encrypt Token Data

Generates an encrypted token for use with Token-Based Authentication. Integrating this capability into your script provides the means to dynamically generate links to content requiring Token-Based Authentication validation.

Token data encryption does not affect CDN configuration. Rather, this endpoint provides a convenient method for incorporating token generation from within your script.

Request

A request to encrypt data as a token value is described below.

HTTP Method Request URI

PUT

https://api.edgecast.com/v2/mcc/token/encrypt

Request Headers

This endpointIdentifies a request's connection point to our REST API service. only takes advantage of common request headers.

Request Body

Pass the following request body parameters:

Name Data Type Description

Key

Required

String

Indicates the primary Token-Based Authentication key associated with the specified platform.

TokenParameter

Required

String

Identifies the criteria that a user agent must meet before an asset will be served to that client. The format for each criterion is the token parameter, an equal sign, and the value that the client must meet. If you would like to specify multiple requirements, then each token parameter/value pair must be delimited using an ampersand (e.g., ec_expire=1356955200&ec_country_deny=CA&ec_country_allow=US,MX).

Generate this syntax through the encrypt tool that is provided from the Token-Based Authentication page in the MCC.

An ampersand (&) is a reserved character in XML. Make sure to specify each ampersand using its entity reference (i.e., &).

Response

The response to the above request includes an HTTP status code, response headers, and a response body.

Status Code

A status code indicates whether the request was successfully performed.

Response Headers

The response for this endpoint only includes standard HTTP response headers.

View common response headers.

Response Body

The response body for a successful request contains the following response parameter:

Name Data Type Description

Token

String

Indicates the encrypted token value generated from the criteria specified in the TokenParameter request parameter. This token value can be specified as a query string parameter in a request URL to gain access to content secured by Token-Based Authentication.

Errors

The response body for an unsuccessful request may contain an error parameter that provides additional information.

View common error messages.

Sample Request and Response (JSON)

A sample JSON request is provided below.

PUT https://api.edgecast.com/v2/mcc/token/encrypt HTTP/1.1

Authorization: TOK:12345678-1234-1234-1234-1234567890ab

Accept: application/json

Content-Type: application/json

Host:api.edgecast.com

Content-Length: 137

{
	"Key" : "MyPrimaryKeyTBA",
	"TokenParameter" : "ec_expire=1356955200&ec_country_deny=CA&ec_country_allow=US,MX",
	"TokenVersion" : "V3"
}

A sample JSON response is provided below.

HTTP/1.1 200 OK

Cache-Control: private

Content-Type: application/json; charset=utf-8

Date: Thu, 15 Apr 2021 12:00:00 GMT

Content-Length: 204

{
	"Token" : "c17fe661298545b8c6c39808e4c6c32a87a215a1d3bfdb2ebd2ec06c9ce42538767ce212e8aa17689f1511033fdd302f98a487abc821bf3726b845afeded843c79b82686f46d61da6a296e3b"
}

Sample Request and Response (XML)

A sample XML request is provided below.

PUT https://api.edgecast.com/v2/mcc/token/encrypt HTTP/1.1

Authorization: TOK:12345678-1234-1234-1234-1234567890ab

Accept: application/xml

Content-Type: application/xml

Host:api.edgecast.com

Content-Length: 227

<TokenParamValues xmlns="http://www.whitecdn.com/schemas/apiservices/">
	<Key>MyPrimaryKeyTBA</Key>
	<TokenParameter>ec_expire=1356955200&amp;ec_country_deny=CA&amp;ec_country_allow=US,MX</TokenParameter>
	<TokenVersion>V3</TokenVersion>
</TokenParamValues>

A sample XML response is provided below.

HTTP/1.1 200 OK

Cache-Control: private

Content-Type: application/xml; charset=utf-8

Date: Thu, 15 Apr 2021 12:00:00 GMT

Content-Length: 336

<EncryptedToken xmlns="http://www.whitecdn.com/schemas/apiservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
	<Token> c17fe661298545b8c6c39808e4c6c32a87a215a1d3bfdb2ebd2ec06c9ce42538767ce212e8aa17689f1511033fdd302f98a487abc821bf3726b845afeded843c79b82686f46d61da6a296e3b</Token>
</EncryptedToken>