Signature Generation Formula
signature = base64(HMAC-SHA256(secret_key, signingString))Where:
secret_keyis the token used when creating the tasksigningStringis the signing string, constructed according to the following format
Signing String Construction Method
signingString = http_method + "\n" + http_uri + "\n" + canonical_query_string + "\n" + access_key + "\n" + Date + "\n" + signed_headers_stringParameter descriptions:
http_method: HTTP request methods defined in the HTTP protocol such as GET, PUT, POST, etc., must be in uppercase formhttp_uri: The path portion of the URL, extracted from callback_url using standard URL parsing. It must start with "/"; an empty path is "/"canonical_query_string: The query parameter portion of the URL, extracted from callback_url using standard URL parsing. If there are no query parameters, this is an empty stringaccess_key: API identifier, fixed as "vidu"Date: The Date in the request header (GMT format)signed_headers_string: Headers specified by X-HMAC-SIGNED-HEADERS, taken from the request headers in order and concatenated in the following format:
Request Headers
The request headers related to signing include:
Date: GMT-format time, for example: "Tue, 06 May 2025 12:09:42 GMT"x-request-nonce: Random string used to prevent replay attacksX-HMAC-SIGNED-HEADERS: List of header fields used in the signature, separated by semicolons, for example: "Date;x-request-nonce"X-HMAC-SIGNATURE: The final computed signatureX-HMAC-ALGORITHM: Signature algorithm, fixed as "hmac-sha256"X-HMAC-ACCESS-KEY: Access key identifier, fixed as "vidu"
Example
Sample Request
Generated Signing String
Using a standard URL parsing library to parse the full URL http://127.0.0.1:8080/vidu/callback?name=james&age=36, the final generated signing string is:
Note:
- There is a trailing newline character at the end of the string
/vidu/callbackis the Path portion extracted from the URL using a standard URL parsing libraryname=james&age=36is the RawQuery portion extracted from the URL using a standard URL parsing library- The key used for signing is the application's TokenSecret
Python Implementation Example
Go Implementation Example
Notes
- The signing string is very sensitive to formatting, including newlines and spaces
- When using multi-line strings, you must ensure:
- There are no extra leading spaces
- The format of each line is precise
- There is a trailing newline character at the end of the string
- The headers specified by X-HMAC-SIGNED-HEADERS must be concatenated in the specified order
- The HTTP method must be uppercase (e.g. POST, GET, etc.)
- The URI must start with "/"
- Query parameters must use the raw format and must not include "?"
- During the signing process, the system uses a standard URL parsing library to extract the URI and query parameter portions from callback_url
- To prevent replay attacks, the x-request-nonce request header should contain a random value (UUID format)