サーバーサイド広告スティッチングの場合、マニフェスト マニピュレータは Google DAI に連続配信広告セグメントのリクエストを行います。詳しくは、広告セグメントの URL を作成するをご覧ください。
このページでは、HMAC トークンを使用して連続配信広告セグメント リクエストを認証する方法について説明します。
始める前に
続行する前に、次のことを行ってください。
- 前提条件を満たしている。
- Google アド マネージャー アカウントのライブ配信イベントで、Pod リソース認証鍵が有効になっていることを確認します。
HMAC トークンを生成する
トークンを生成する手順は次のとおりです。
- Pod セグメント リクエストに入力されたパス パラメータとクエリ パラメータ(auth-token を除く)を収集します。完全なリストについては、メソッド: pod セグメントをご覧ください。
パラメータを 1 つの文字列にまとめます。パラメータはアルファベット順に並べ替え、チルダ
~文字で区切る必要があります。例:custom_asset_key=CUSTOM_ASSET_KEY~exp=EXPIRATION~network_code=NETWORK_CODE~pd=POD_DURATION~pod_id=POD_IDENTIFIERDAI 認証鍵を使用して、トークン文字列の SHA-256 ハッシュを計算します。
ハッシュ出力を 16 進数でフォーマットします。
トークン文字列に署名するには、前に収集したパラメータの末尾に署名を追加します。
custom_asset_key=...~hmac=HMAC_SIGNATUREHMAC_SIGNATUREは、DAI 認証キーを使用してトークン文字列をハッシュ化して生成した署名に置き換えます。署名付きトークン文字列を安全に渡すには、署名付きトークン文字列に URL エンコードを適用します。
次の例では、署名付きトークン文字列の URL エンコードされた値を生成します。
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
HLS 連続配信広告セグメント リクエストを認証する
Pod リソース リクエストを認証するには、auth-token クエリ文字列パラメータを使用して、URL エンコードされた署名付き HMAC トークンを渡します。
HLS
次の例では、HMAC トークンを使用して HLS Pod セグメント リクエストを認証します。
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"
成功すると、次のレスポンスが表示されます。
...
< 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
...
レスポンスの構造とステータス コードについては、メソッド: pod セグメントをご覧ください。
認証に失敗すると、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
次の例では、HMAC トークンを使用して DASH Pod セグメント リクエストを認証します。
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"
成功すると、次のレスポンスが表示されます。
...
HTTP/2 302
..
location: https://redirector.googlevideo.com/....
...
レスポンスの構造とステータス コードについては、メソッド: pod セグメントをご覧ください。
認証に失敗すると、次のように 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
...