> For the complete documentation index, see [llms.txt](https://clients.medianova.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clients.medianova.com/products/security/security-token/streaming-secure-token.md). Agents can also search and read this documentation through its [MCP server](https://clients.medianova.com/~gitbook/mcp).

# Streaming Secure Token

Learn how to configure Streaming Secure Token and generate signed URLs for live and on-demand video delivery.

Streaming Secure Token protects live and video-on-demand (VOD) content using signed, time-limited URLs.

It supports directory-based signing, optional query parameter protection, and two token formats: standard `st` and `e` parameters or a single `hdnts` parameter.

With directory-based signing, one token can authorize a streaming playlist and its segments within the supported directory scope.

## How Streaming Secure Token works

Streaming Secure Token generates an MD5 signature using an expiration timestamp, a secret key, and optional request values.

Your application generates the signed URL. Medianova CDN validates the signature and expiration time before processing protected requests.

The process includes four stages:

1. **Token generation:** Your backend signs the expiration timestamp, Token Key, and configured optional values.
2. **Content request:** The viewer requests a signed playlist, segment, or media file.
3. **Token validation:** Medianova CDN calculates the expected signature using the configured settings.
4. **Request handling:** The CDN processes valid requests and rejects requests that fail validation.

The Token Key remains on your backend and in the CDN Resource configuration.

{% hint style="info" %}
Streaming Secure Token does not bind URLs to a viewer's IP address. Use Streaming Secure Token – IP Lock when IP-based restrictions are required.
{% endhint %}

## Supported CDN Resource types

Streaming Secure Token is available for:

| CDN Resource type | Availability                         |
| ----------------- | ------------------------------------ |
| Small CDN         | Not supported                        |
| Large CDN         | Not supported                        |
| Large Streaming   | Not supported                        |
| Streaming         | Supported                            |
| VOD               | Supported through Streaming delivery |
| Dynamic CDN       | Not supported                        |

## Understand signing options

Streaming Secure Token supports three configurable options.

<table><thead><tr><th width="204">Option</th><th>Behavior</th></tr></thead><tbody><tr><td><strong>Token URI</strong></td><td>Includes the stream directory in the signature when enabled.</td></tr><tr><td><strong>Query parameters</strong></td><td>Includes selected query parameter values in the signature.</td></tr><tr><td><strong>Third-party format</strong></td><td>Uses one <code>hdnts</code> parameter instead of separate <code>st</code> and <code>e</code> parameters.</td></tr></tbody></table>

### Understand Token URI behavior

<table><thead><tr><th width="102">Token URI</th><th width="361.5">Signed values</th><th>Access scope</th></tr></thead><tbody><tr><td>Enabled</td><td>Expiration, Token Key, directory, optional query values</td><td>Files within the supported signed directory scope</td></tr><tr><td>Disabled</td><td>Expiration, Token Key, optional query values</td><td>All paths within the CDN Resource</td></tr></tbody></table>

{% hint style="warning" %}
Disabling Token URI removes directory restrictions. A valid token can authorize other paths within the CDN Resource until expiration.
{% endhint %}

## Configure Streaming Secure Token

Use the [Medianova Control Panel](https://cloud.medianova.com) to configure Streaming Secure Token.

{% stepper %}
{% step %}

### Select a CDN Resource

Open the Streaming CDN Resource you want to protect in the [Medianova Control Panel](https://cloud.medianova.com).
{% endstep %}

{% step %}

### Open Security settings

Navigate to **Security → General**.
{% endstep %}

{% step %}

### Enable Security Token

Enable **Security Token**.
{% endstep %}

{% step %}

### Select Streaming Secure Token

Choose **Streaming Secure Token** from **Token Type**.

<figure><img src="https://542970813-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtK7oIwmhUHdEJcaH4Hx8%2Fuploads%2FIZyjmtenj4dXQDuzUZ5d%2Fimage.png?alt=media&amp;token=d0992649-eeac-4ac4-93a6-9242921c2435" alt=""><figcaption><p>Streaming Secure Token configuration for a Streaming Resource.</p></figcaption></figure>
{% endstep %}

{% step %}

### Configure the Token Key

Enter your secret key in **Token Key**.

Use a randomly generated alphanumeric key of at least 32 characters.
{% endstep %}

{% step %}

### Configure Token URI

Enable **Token URI** to include the stream directory in the signature.

Disable it only when path-independent access is required.
{% endstep %}

{% step %}

### Configure query parameters

Specify the query parameter names whose values must be protected by the signature.

Leave the list empty when no additional parameters require protection.
{% endstep %}

{% step %}

### Select the token format

Use the standard format or enable the third-party format when your integration requires `hdnts`.
{% endstep %}

{% step %}

### Save the configuration

Click **Save** to apply your settings.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Changing the Token Key invalidates URLs generated with the previous key. Keep the key confidential.
{% endhint %}

## Generate a standard signed URL

The standard format uses two required query parameters.

<table><thead><tr><th width="265.5">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>st</code></td><td>MD5 signature encoded using Base64URL without padding.</td></tr><tr><td><code>e</code></td><td>Expiration time as a Unix timestamp in seconds.</td></tr></tbody></table>

### Calculate the signature

When Token URI is enabled, use:

```
st = base64url(MD5(e + " " + KEY + " " + DIRECTORY))
```

Where:

* `e` is the expiration timestamp.
* `KEY` is the configured Token Key.
* `DIRECTORY` is the normalized stream directory.

Use exactly one space between the values.

When Token URI is disabled, use:

```
st = base64url(MD5(e + " " + KEY))
```

The signature uses the raw 16-byte MD5 digest encoded with Base64URL. Remove trailing `=` padding.

### Verify the standard signature

Use the following test values:

| Input           | Value                         |
| --------------- | ----------------------------- |
| Token Key       | `ExampleKey2026`              |
| File path       | `/live/stream1/playlist.m3u8` |
| Directory       | `/live/stream1/`              |
| Expiration      | `1798761600`                  |
| Expiration date | 2027-01-01 00:00:00 UTC       |

The signed string is:

```
1798761600 ExampleKey2026 /live/stream1/
```

The expected signature is:

```
o7BgjmaV0gALato-9cB67g
```

The resulting URL is:

```
https://cdn.example.com/live/stream1/playlist.m3u8?st=o7BgjmaV0gALato-9cB67g&e=1798761600
```

The same signature can authorize supported segment requests within the signed directory scope.

{% hint style="warning" %}
The example key is for testing only. Never use it to protect production content.
{% endhint %}

## Generate a third-party signed URL

The third-party format uses a single `hdnts` query parameter.

Its value contains the expiration timestamp and signature, separated by `~`.

Use this structure:

```
hdnts=e=<EXPIRATION>~st=<SIGNATURE>
```

The signature calculation follows the same MD5 and Base64URL method as the standard format.

### Verify the third-party example

Using the previous test values, the signature remains:

```
o7BgjmaV0gALato-9cB67g
```

The resulting URL is:

```
https://cdn.example.com/live/stream1/playlist.m3u8?hdnts=e=1798761600~st=o7BgjmaV0gALato-9cB67g
```

Do not percent-encode the `=` or `~` separators inside `hdnts`.

{% hint style="info" %}
The third-party format always uses UTC for expiration validation. It does not apply the Token Timezone offset used by the standard format.
{% endhint %}

## Protect selected query parameters

Streaming Secure Token can include configured query parameter values in the signature.

For example, you can protect a `userId` parameter against modification.

### Configure signed parameters

Specify the parameter names in the Medianova Control Panel.

For the standard format, names can contain letters, digits, and underscores.

For the third-party format, use only letters and digits.

The order of the configured names determines the order of their values in the signature.

### Calculate a signature with query parameters

Append each configured parameter value to the signed string, preceded by one space.

For example, when Token URI is enabled and `userId` is configured:

```
SIGNED_STRING =
e + " " + KEY + " " + DIRECTORY + " " + USER_ID
```

Use the parameter value exactly as it appears in the URL.

For the standard format, send the parameter separately:

```
https://cdn.example.com/live/stream1/playlist.m3u8?st=<SIGNATURE>&e=<EXPIRATION>&userId=42
```

For the third-party format, include it inside `hdnts`:

```
https://cdn.example.com/live/stream1/playlist.m3u8?hdnts=e=<EXPIRATION>~st=<SIGNATURE>~userId=42
```

Replace the placeholders with your generated values.

{% hint style="warning" %}
Every configured query parameter must appear inside `hdnts` when using the third-party format. The source implementation reports HTTP 500 when a required parameter is missing.
{% endhint %}

## Generate signed URLs with Python

The following example supports both token formats, directory signing, and selected query parameters.

It reads the Token Key from an environment variable and generates a URL valid for one hour.

```python
import base64
import hashlib
import os
import time
from urllib.parse import urlencode


def sign_url(
    base_url: str,
    path: str,
    key: str,
    ttl: int,
    token_uri: bool = True,
    third_party: bool = False,
    signed_params: dict[str, str] | None = None,
) -> str:
    expiration = int(time.time()) + ttl

    signed_params = signed_params or {}

    signed_parts = [str(expiration), key]

    if token_uri:
        directory = path[:path.rfind("/") + 1]

        directory = directory.replace(
            "/keyframes/",
            "/",
        )

        signed_parts.append(directory)

    signed_parts.extend(signed_params.values())

    signed_data = " ".join(signed_parts)

    digest = hashlib.md5(
        signed_data.encode("utf-8")
    ).digest()

    signature = (
        base64.urlsafe_b64encode(digest)
        .rstrip(b"=")
        .decode("ascii")
    )

    if third_party:
        hdnts = f"e={expiration}~st={signature}"

        for name, value in signed_params.items():
            if not name.isalnum():
                raise ValueError(
                    "Third-party parameter names "
                    "must be alphanumeric."
                )

            hdnts += f"~{name}={value}"

        return f"{base_url}{path}?hdnts={hdnts}"

    params = {
        "st": signature,
        "e": str(expiration),
        **signed_params,
    }

    return (
        f"{base_url}{path}?"
        f"{urlencode(params)}"
    )


url = sign_url(
    base_url="https://cdn.example.com",
    path="/live/stream1/playlist.m3u8",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    token_uri=True,
)

print(url)
```

Set `MN_TOKEN_KEY` to the Token Key configured in the Medianova Control Panel.

Replace the example hostname and stream path with your actual values.

Set `token_uri` and `third_party` to match the Control Panel configuration.

To protect an additional query parameter, pass it using `signed_params`:

```python
url = sign_url(
    base_url="https://cdn.example.com",
    path="/live/stream1/playlist.m3u8",
    key=os.environ["MN_TOKEN_KEY"],
    ttl=3600,
    token_uri=True,
    signed_params={"userId": "42"},
)
```

{% hint style="warning" %}
Generate signed URLs on a trusted backend. Never expose the Token Key in player code, browser scripts, or mobile applications.
{% endhint %}

## Follow streaming directory rules

When Token URI is enabled, the signature includes the directory of the requested stream path.

The directory ends at the final `/` before the file name.

For example:

| Requested path                | Signed directory |
| ----------------------------- | ---------------- |
| `/live/stream1/playlist.m3u8` | `/live/stream1/` |
| `/live/stream1/segment001.ts` | `/live/stream1/` |
| `/live/stream2/playlist.m3u8` | `/live/stream2/` |

A signature for `/live/stream1/` does not automatically authorize `/live/stream2/`.

### Handle HLS requests

For HLS, the same directory signature can authorize the playlist and segments stored in that directory.

Each request must include a valid token.

### Handle DASH and Smooth Streaming requests

For DASH and Smooth Streaming, the source implementation checks segments against the directory one level above their own.

Keep segment files in a subdirectory of the manifest directory.

For example:

```
/live/stream1/manifest.mpd
/live/stream1/video/segment001.m4s
```

Sign the manifest directory:

```
/live/stream1/
```

### Handle keyframe paths

The source implementation removes every `/keyframes` path component from the signed directory.

For example:

```
Requested directory:
/live/keyframes/stream1/

Signed directory:
/live/stream1/
```

Use the normalized directory when generating signatures.

## Manage token expiration

The `e` parameter defines when the signed URL expires.

Use a Unix timestamp in seconds.

For example, a one-hour token uses:

```
EXPIRATION = CURRENT_UNIX_TIME + 3600
```

### Choose an expiration period

Streaming sessions can generate multiple requests for playlists and segments.

Each request must carry a valid token.

Use an expiration period longer than the expected viewing session, or implement token renewal.

A request started before expiration can complete. New requests after expiration are rejected.

### Understand Token Timezone

The standard format supports a Token Timezone setting.

The source implementation compares the expiration timestamp against the current time adjusted by the configured UTC offset.

The third-party format always uses UTC.

{% hint style="info" %}
Use UTC for Token Timezone unless your integration specifically requires another setting. Keep your application clock synchronized.
{% endhint %}

## Deploy Streaming Secure Token safely

Prepare your streaming application before enabling token enforcement.

{% stepper %}
{% step %}

### Generate a Token Key

Create a secure key and store it in your application's secret management system.
{% endstep %}

{% step %}

### Implement URL signing

Add Streaming Secure Token signature generation to your backend.
{% endstep %}

{% step %}

### Validate the signing implementation

Compare the generated signature with the worked example on this page.
{% endstep %}

{% step %}

### Update your streaming player

Configure the player to request signed playlists and media segments.
{% endstep %}

{% step %}

### Verify token propagation

Confirm that all protected streaming requests include valid token parameters.
{% endstep %}

{% step %}

### Update cached links

Purge or replace cached pages that contain unsigned streaming URLs.
{% endstep %}

{% step %}

### Enable Streaming Secure Token

Apply the prepared configuration in the Medianova Control Panel.
{% endstep %}

{% step %}

### Test protected playback

Verify valid, invalid, expired, and unsigned requests.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
Enabling Security Token immediately rejects unsigned protected requests. Verify playlist and segment URL handling before enforcement.
{% endhint %}

## Validate protected requests

The source technical guide documents these responses:

| Condition                               | Expected response                    |
| --------------------------------------- | ------------------------------------ |
| Valid signature and expiration          | Request proceeds to content delivery |
| Missing signature                       | 403 Forbidden                        |
| Invalid signature                       | 403 Forbidden                        |
| Expired token                           | 410 Gone                             |
| Missing configured parameter in `hdnts` | 500 Internal Server Error            |

The third-party format checks expiration before signature validation. At the expiration boundary, the source implementation can return HTTP 410 even when the signature is invalid.

A valid token does not guarantee HTTP 200. Content availability and other CDN settings still affect the final response.

## Troubleshoot Streaming Secure Token

### HTTP 403 Forbidden

The CDN rejects requests that fail token validation.

Check the following:

* The Token Key matches the configured key.
* The token format matches the CDN configuration.
* The Token URI setting matches the signing method.
* The signed directory matches the requested path.
* The signature uses the raw MD5 digest.
* Base64URL encoding excludes `=` padding.
* The signed values use exactly one space as a separator.
* Configured query parameters appear in the correct order.
* The URL has not been modified during delivery.

Compare your generated signature with the worked example:

```
o7BgjmaV0gALato-9cB67g
```

### HTTP 410 Gone

HTTP 410 indicates an expired token in the source implementation.

Generate a new signed URL with a future expiration timestamp.

Verify that the application clock and Token Timezone configuration are correct.

### The playlist works but segments fail

Check whether segment requests include valid token parameters.

Verify the directory structure and signing rules for the streaming protocol.

For HLS, confirm that playlist and segment paths match the expected directory scope.

For DASH and Smooth Streaming, check the parent-directory signing behavior.

### The third-party token fails

Check the `hdnts` structure.

Verify that the token contains `e` and `st` separated by `~`.

Ensure every configured query parameter appears inside `hdnts`.

Do not percent-encode the internal `=` and `~` separators.

### A token stops working after a key change

Changing the Token Key invalidates URLs generated with the previous key.

Update your application's signing key and generate new URLs.

### Streaming playback stops after some time

The token may expire during playback.

Use a longer expiration period or implement token renewal.

Remember that playlist and segment requests are validated separately.

## Security recommendations

* Store the Token Key in a secure backend environment.
* Use directory-based signing when stream-level restrictions are required.
* Keep token expiration periods appropriate for viewing sessions.
* Protect sensitive query parameter values by including them in the signature.
* Use HTTPS when delivering streaming content.
* Keep application clocks synchronized.
* Test playback across supported streaming protocols.
* Coordinate Token Key changes with player and backend updates.
* Monitor HTTP 403 and 410 responses after enabling enforcement.

{% hint style="warning" %}
Signed streaming URLs act as temporary access credentials. Anyone with a valid URL can reuse it until expiration, subject to other configured restrictions.
{% endhint %}

## Related token types

For different access requirements, consider:

* [**Streaming Secure Token – IP Lock**](https://clients.medianova.com/products/security/security-token/streaming-secure-token-ip-lock.md)**:** Restrict streaming access to a viewer's IP address.
* [**Secure Token v2**](https://clients.medianova.com/products/security/security-token/secure-token-v2.md)**:** Protect directories or an entire CDN Resource.
* [**MD5 Secure Token**](https://clients.medianova.com/products/security/security-token/md5-secure-token.md)**:** Generate hexadecimal MD5 signatures for supported delivery platforms.

{% hint style="info" %}
For general feature configuration, refer to the [Security Token](https://clients.medianova.com/products/security/security-token.md) page.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://clients.medianova.com/products/security/security-token/streaming-secure-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
