สำหรับการต่อโฆษณาฝั่งเซิร์ฟเวอร์ ตัวจัดการไฟล์ Manifest จะส่งคำขอพ็อดโฆษณา ไปยัง Google DAI ดูข้อมูลเพิ่มเติมได้ที่สร้าง URL ของกลุ่มโฆษณา
หน้านี้ครอบคลุมการตรวจสอบสิทธิ์คำขอกลุ่มพ็อดโฆษณาโดยใช้โทเค็น HMAC
ก่อนเริ่มต้น
ก่อนดำเนินการต่อ ให้ทำดังนี้
- ทำตามข้อกำหนดเบื้องต้น
- ตรวจสอบว่าได้เปิดใช้คีย์การตรวจสอบสิทธิ์ของทรัพยากรพ็อดในกิจกรรมสตรีมสดในบัญชี Google Ad Manager
สร้างโทเค็น HMAC
หากต้องการสร้างโทเค็น ให้ทำดังนี้
- รวบรวมพารามิเตอร์เส้นทางและพารามิเตอร์การค้นหา (ยกเว้นโทเค็นการให้สิทธิ์) ที่สร้างขึ้นสําหรับคําขอเซ็กเมนต์พ็อด ดูรายการทั้งหมดได้ที่เมธอด: พ็อดเซ็กเมนต์
จัดระเบียบพารามิเตอร์เป็นสตริงเดียว คุณต้องจัดเรียงพารามิเตอร์ตามตัวอักษร และคั่นด้วยอักขระทิลด้า
~เช่นcustom_asset_key=CUSTOM_ASSET_KEY~exp=EXPIRATION~network_code=NETWORK_CODE~pd=POD_DURATION~pod_id=POD_IDENTIFIERคำนวณแฮช SHA-256 ของสตริงโทเค็นโดยใช้คีย์การตรวจสอบสิทธิ์ DAI
จัดรูปแบบเอาต์พุตแฮชในเลขฐานสิบหก
หากต้องการลงนามในสตริงโทเค็น ให้ต่อท้ายลายเซ็นที่ท้ายพารามิเตอร์ที่รวบรวมไว้ก่อนหน้านี้
custom_asset_key=...~hmac=HMAC_SIGNATUREแทนที่
HMAC_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
หากต้องการตรวจสอบสิทธิ์คำขอทรัพยากรพ็อด ให้ใช้พารามิเตอร์auth-tokenสตริงการค้นหา
เพื่อส่งโทเค็น HMAC ที่ลงนามและเข้ารหัส URL
HLS
ตัวอย่างต่อไปนี้ใช้โทเค็น HMAC เพื่อตรวจสอบสิทธิ์คำขอพ็อดเซ็กเมนต์ 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"
หากสำเร็จ คุณจะเห็นการตอบกลับต่อไปนี้
...
< 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
...
หากต้องการทําความเข้าใจโครงสร้างการตอบกลับและรหัสสถานะ โปรดดูวิธี: กลุ่มพ็อด
หากการตรวจสอบสิทธิ์ไม่สำเร็จ คุณจะเห็น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
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/....
...
หากต้องการทําความเข้าใจโครงสร้างการตอบกลับและรหัสสถานะ โปรดดูวิธี: กลุ่มพ็อด
หากการตรวจสอบสิทธิ์ไม่สำเร็จ คุณจะเห็น 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
...