This guide explains how to create a signature, and the required and optional fields for signatures.
To create a signature, you compose a string to sign, which we refer to as a signed value in this guide. The signed value includes parameters that describe the content you are protecting, the expiration time of the signed value, and so forth.
You use the signed value while creating a signature string. You create a signature string by composing the parameters for the signature, such as an asymmetric-key Ed25519 signature of the signed value.
Media CDN uses the final composed signature to help protect your content.
Supported signing formats
Media CDN supports the following signed request formats.
| Format | Behavior | Example |
|---|---|---|
| Query parameters (exact URL) |
Exact URL, for granting access to a specific URL. |
Exact:
|
| Query parameters (URL prefix) |
Specifying a URLPrefix lets you sign a prefix and append
the same query parameters to multiple URLs within your player or manifest
generation.
|
What to sign:
Replace |
| Path component |
Prefix: allows access to any URL with a prefix prior to the
This allows relative manifest URLs to automatically inherit the signed URL component when fetching sub-resources. |
https://media.example.com/video/edge-cache-token=Expires=EXPIRATION
|
| Signed cookie | Prefix: the cookie allows access to any URL with the prefix specified
in the signed URLPrefix value.
|
Edge-Cache-Cookie:
|
Create a signature
Create a signed value by concatenating a string that contains the required signature fields and desired optional signature fields.
If specified,
URLPrefixmust come first, followed byExpires,KeyName, and then any optional parameters.Separate each field and any parameters with the following:
- For cookies, use a colon
:character. - For query parameters and path components, use an ampersand
&character.
- For cookies, use a colon
Sign the signed value with an Ed25519 signature.
Append a field separator (either
:or&) followed bySignature=and the Ed25519 signature to the end of the string.
Create a signed URL
The following code samples shows how to programmatically create a signed URL.
Go
To authenticate to Media CDN, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To authenticate to Media CDN, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.