Collect the required information for your client applications
You should have the following information that is required for Google Ad Manager to create a VOD asset session:
Field | Description |
---|---|
projectNumber | The Google Cloud project number used to create Ad Manager-enabled sessions; alternatively, you can use the project ID. |
region |
The region that you want the IMA SDK to use to create the VOD session. |
sourceUri | The URI of your VOD asset to stitch ads into. |
adTagUri | The ad tag to mark how many ads should be stitched and when. See Create an ad tag for a VOD session. |
networkCode | The numeric identifier for your Ad Manager network. |
OAuth token | A short-lived OAuth token for the service account with the Video Stitcher User role. See Generate short-lived OAuth tokens. |
Table 1. Required information for Ad Manager-enabled VOD asset sessions
Create an ad tag for a VOD session
Perform the following steps in your Ad Manager account:
- Add a new ad unit.
- Activate ad rules.
Create a new ad rule. As part of this step, find the Targeting > Inventory section in Ad Manager. Select the new ad unit from the previous step.
Create a valid ad tag by following the steps on Generate video and audio ad tags with the following modifications:
- For the Player SDK type, select Google IMA SDK.
- Add the parameter
ad_rule=1
to the tag (for example, add&ad_rule=1
to the end). - Add the parameter
vid_d=<vod_asset_duration_in_secs>
to the tag (for example, add&vid_d=1800
to the end for a 30 minute VOD asset). - Modify the parameter
output=vast
to beoutput=xml_vmap1
. The Video Multiple Ad Playlist (VMAP) specification is the only supported output type.
Generate short-lived OAuth tokens
To generate a short-lived OAuth token associated with the service account with the Video Stitcher User role, follow these steps:
- Replace PATH_TO_YOUR_SERVICE_KEY with the path to the JSON file
you downloaded to your local machine.
gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY
- Retrieve the OAuth 2.0 bearer token from the service account:
gcloud auth print-access-token
Because this is a short-lived token, you need to generate it again
periodically with the gcloud auth print-access-token
command and send the new
tokens to your client applications. See the following section for more
information.
(Optional) Create a service to provide information to your client applications
We recommend that you build a service that can provide the required information (including the OAuth token) to be passed to the client. The service account associated with the service must have the Service Token Creator role and creates an OAuth token for the service account that has the Video Stitcher User role.
When the application requests information from your service on how to play a VOD asset, the service should return the information described in Table 1.