Per lo stitching degli annunci lato server, il manipolatore del manifest effettua richieste di segmenti di pod di annunci al DAI di Google. Per saperne di più, consulta Creare URL di segmenti di annunci.
Questa pagina illustra l'autenticazione delle richieste di segmenti di pod di annunci utilizzando il token HMAC.
Prima di iniziare
Prima di continuare, completa queste operazioni:
- Completa i prerequisiti.
- Assicurati che le chiavi di autenticazione delle risorse pod siano attive nell'evento live streaming nel tuo account Google Ad Manager.
Generare un token HMAC
Per generare un token:
- Raccogli i parametri di percorso e query (ad eccezione di auth-token) compilati per la richiesta di segmento di pod. Per un elenco completo, consulta Metodo: segmento di pod.
Organizza i parametri in un'unica stringa. Devi ordinare i parametri in ordine alfabetico e separarli con il carattere tilde
~, ad esempio:custom_asset_key=CUSTOM_ASSET_KEY~exp=EXPIRATION~network_code=NETWORK_CODE~pd=POD_DURATION~pod_id=POD_IDENTIFIERCalcola un hash SHA-256 della stringa del token utilizzando la chiave di autenticazione DAI.
Formatta l'output dell'hash in formato esadecimale.
Per firmare la stringa del token, aggiungi la firma alla fine dei parametri raccolti in precedenza:
custom_asset_key=...~hmac=HMAC_SIGNATURESostituisci
HMAC_SIGNATUREcon la firma che hai generato eseguendo l'hashing della stringa del token utilizzando la chiave di autenticazione DAI.Per trasmettere in modo sicuro la stringa del token firmato, applica la codifica URL alla stringa del token firmato.
L'esempio seguente genera il valore con codifica URL di una stringa di token firmata:
HLS
# Add 60 seconds to the current time
future_epoch=$((EPOCHSECONDS + 60))
echo "Current: $EPOCHSECONDS"
echo "Future: $future_epoch"
# Current: 1774465950
# Future: 1774466010
# Sample DAI pod resource authentication key
key="EB08..."
# Sort parameters in the token string
token="ad_break_id=ab1~custom_asset_key=hls-pod-serving-redirect-auth-stream-pod~exp=1774466010~network_code=21775744923~pd=30000"
# Generate the token's signature.
echo -n $token | openssl dgst -sha256 -mac HMAC -macopt key:$key
# SHA2-256(stdin)= ff38abab31b436351e20ecd57bcc5b97acd9461abb71c4cf9c9731add965ecf2
# Sign the token: ad_break_id=ab1~custom_asset_key=hls-pod-serving-redirect-auth-stream-pod~exp=1774466010~network_code=21775744923~pd=30000~hmac=ff38abab31b436351e20ecd57bcc5b97acd9461abb71c4cf9c9731add965ecf2
# Encode the token: ad_break_id%3Dab1~custom_asset_key%3Dhls-pod-serving-redirect-auth-stream-pod~exp%3D1774466010~network_code%3D21775744923~pd%3D30000~hmac%3Dff38abab31b436351e20ecd57bcc5b97acd9461abb71c4cf9c9731add965ecf2
DASH
# Add 60 seconds to the current time
future_epoch=$((EPOCHSECONDS + 60))
echo "Current: $EPOCHSECONDS"
echo "Future: $future_epoch"
# Current: 1769540517
# Future: 1769540577
# Sample DAI pod resource authentication key
key="EB08..."
# Sort parameters in the token string
token="ad_break_id=ab1~custom_asset_key=dash-pod-serving-redirect-auth-stream-pod~exp=1774466641~network_code=21775744923~pd=30000"
# Generate the token's signature.
echo -n $token | openssl dgst -sha256 -mac HMAC -macopt key:$key
# SHA2-256(stdin)= 7249f9193778f2318314519ff2cea5c47958bc7fdd2eaf24008352867af0a050
# Sign the token: ad_break_id=ab1~custom_asset_key=dash-pod-serving-redirect-auth-stream-pod~exp=1774466641~network_code=21775744923~pd=30000~hmac=7249f9193778f2318314519ff2cea5c47958bc7fdd2eaf24008352867af0a050
# Encode the token: ad_break_id%3Dab1~custom_asset_key%3Ddash-pod-serving-redirect-auth-stream-pod~exp%3D1774466641~network_code%3D21775744923~pd%3D30000~hmac%3D7249f9193778f2318314519ff2cea5c47958bc7fdd2eaf24008352867af0a050
Autenticare una richiesta di segmento di pod di annunci HLS
Per autenticare le richieste di risorse pod, utilizza il parametro della stringa di query auth-token per trasmettere il token HMAC firmato codificato in URL.
HLS
L'esempio seguente utilizza un token HMAC per autenticare una richiesta di segmento di pod HLS:
curl --include "https://dai.google.com/linear/pods/v1/seg/network/21775744923/custom_asset/hls-pod-serving-redirect-auth-stream-pod/ad_break_id/ab1/profile/media-ts-4628000bps/0.ts?stream_id=51b85d28-7ed5-48da-bfd8-e013b7d7b204:DLS&&sd=10000&pd=30000&auth-token=ad_break_id%3Dab1~custom_asset_key%3Dhls-pod-serving-redirect-auth-stream-pod~exp%3D1774466010~network_code%3D21775744923~pd%3D30000~hmac%3Dff38abab31b436351e20ecd57bcc5b97acd9461abb71c4cf9c9731add965ecf2"
Se l'operazione ha esito positivo, viene visualizzata la seguente risposta:
...
< HTTP/2 302
< access-control-allow-headers: Authorization
< access-control-allow-origin: *
< access-control-expose-headers: Location
< cache-control: no-cache, no-store, max-age=0, must-revalidate
< date: Wed, 25 Mar 2026 18:13:40 GMT
< expires: Mon, 01 Jan 1990 00:00:00 GMT
< location: https://redirector.googlevideo.com/....
< pragma: no-cache
< x-content-type-options: nosniff
< x-frame-options: SAMEORIGIN
...
Per comprendere la struttura della risposta e i codici di stato, consulta Metodo: segmento di pod.
Se l'autenticazione non va a buon fine, viene visualizzato il messaggio x-ad-manager-dai-warning:
...
< HTTP/2 302
< access-control-allow-headers: Authorization
< access-control-allow-origin: *
< access-control-expose-headers: Location
< cache-control: no-cache, no-store, max-age=0, must-revalidate
< date: Wed, 25 Mar 2026 18:17:21 GMT
< expires: Mon, 01 Jan 1990 00:00:00 GMT
< location: https://redirector.googlevideo.com/....
< pragma: no-cache
< x-ad-manager-dai-warning: Unable to create ad break due to Unauthorized error (skipping ad break creation)
< x-content-type-options: nosniff
...
DASH
L'esempio seguente utilizza un token HMAC per autenticare una richiesta di segmento pod DASH:
curl --include "https://dai.google.com/linear/pods/v1/seg/network/21775744923/custom_asset/dash-pod-serving-redirect-auth-stream-pod/ad_break_id/ab1/profile/media-ts-4628000bps/0.ts?stream_id=8b061ab5-1efc-4e4d-882f-ae3c071df854:ATL&&sd=10000&pd=30000&auth-token=ad_break_id%3Dab1~custom_asset_key%3Ddash-pod-serving-redirect-auth-stream-pod~exp%3D1774466641~network_code%3D21775744923~pd%3D30000~hmac%3D7249f9193778f2318314519ff2cea5c47958bc7fdd2eaf24008352867af0a050"
Se l'operazione ha esito positivo, viene visualizzata la seguente risposta:
...
HTTP/2 302
..
location: https://redirector.googlevideo.com/....
...
Per comprendere la struttura della risposta e i codici di stato, consulta Metodo: segmento di pod.
Se l'autenticazione non va a buon fine, viene visualizzato il seguente x-ad-manager-dai-warning:
...
HTTP/2 302
..
location: https://redirector.googlevideo.com/....
pragma: no-cache
x-ad-manager-dai-warning: Unable to create ad break due to Unauthorized error (skipping ad break creation)
x-content-type-options: nosniff
...