Authenticating your Google Dynamic Ad Insertion (DAI) requests protects your
livestream events and provides the following advantages:

- **Maximize concurrent sessions**: when you enable DAI authentication for your livestream, DAI only registers a new session for authenticated stream requests, preventing unauthenticated requests from exhausting your ad impressions.
- **Flexible configuration** : Authentication is optional and configured at the livestream level. If you enable Hash-Based Message Authentication Code (HMAC) **Stream create authentication keys** in the Google Ad Manager UI, you must include an HMAC token with your requests. If this setting is disabled, authentication isn't required.

## Prerequisites

Before you continue, make sure you have the following
from the
[Google Ad Manager UI](https://admanager.google.com):

- A DAI authentication key with the type **HMAC** . If you don't have one, complete the following:
  1. Navigate to the Google Ad Manager UI.
  2. Go to **Admin** \> **Video and audio**.
  3. Select **DAI authentication keys**.
  4. Click **New DAI authentication key**.
  5. From the drop-down menu, select type **HMAC**.
  6. Select **Save**.
- A livestream configured for DAI.

## Enable authentication for requests to create DAI stream sessions

Google DAI supports the following authentication key types:

- **Hash-based Message Authentication Code (HMAC)**: a cryptographic technique that uses a secret key and a hash function, SHA-256. To verify the authenticity of the app developer and the integrity of the request data, we recommend using the HMAC authentication key.
- **API Key** : an alternative to HMAC. To implement this method, see the [API Key configuration guide](https://support.google.com/admanager/answer/6381445?sjid=5708889558946187783-NA).

To link your HMAC key to your stream, do the following:

1. In the Google Ad Manager UI, navigate to **Video** \> **Live streams**.
2. Select your livestream from the list.
3. Make a note of your livestream's asset key.
4. Enable **Stream create authentication keys**.
5. Select and add the **HMAC Key** you created in the prerequisites.
6. Save your changes.

For more information, see [Set up a livestream for DAI](https://support.google.com/admanager/answer/7294289).

To generate an HMAC token and authenticate stream creation requests, see [Authenticate stream session requests](https://developers.google.com/ad-manager/dynamic-ad-insertion/api/full-service/stream-session-requests)