YouTube
How to configure DataZen to access YouTube.
Pre-Requisite
The recommended approach is to register a new application with YouTube and request
specific access to the YouTube API for this registered application. At a high level, the following steps may
be required to register a new YouTube application.
- Register a YouTube developer account if you don't already have one
- Create a new Google Project if necessary
- Go to the Google Library and enable the YouTube Data API if needed
- Once the API has been added, go to the Credentials page and create a new OAuth ID
Connection String
Once you have configured an application and an OAuth ID, you can create a Central Connection String in DataZen.
YouTube Bearer Tokens expire after a while, but DataZen will automatically generate new tokens using a Refresh Token;
when the Refresh Token expires, you may need to go through this process again.
- In DataZen, choose Configuration -> Central Connection Strings
- Choose New -> HTTP/S Endpoint
- Enter a friendly name for the connection, and specify this HTTP Endpoint URI: https://www.googleapis.com/youtube/v3/channels?part=snippet&mine=true
- Choose Bearer for the authentication
- Click on the Obtain OAuth Token... link
- On the OAuth Setting dropdown, select YouTube OAuth 2.0 Settings option
- Enter your application Client ID in the appropriate field
- Enter your application Client Secret in the appropriate field
- Check that the redirect URI is correct as entered during the OAuth Client ID creation during the Pre Requisites steps
- Specify all the necessary scopes (if unsure, add them all)
- Click on Get Access Token; this will start the authentication and authorization flow - complete this process before proceeding
- Click on Get Bearer Token; the Token and Refresh Token will be automatically filled out
- Click OK
- Specify a Call Rate Limit if desired; this is important to avoid throttling by YouTube.
- Click OK to create/update the Connection String
Reader
You can create a Job Reader that reads data from YouTube. The endpoints you can read from require you to have sufficient permissions as
defined by the Scopes associated with your OAuth 2.0 token. Follow the following steps to read data from YouTube:
- In DataZen, select an Agent, and choose New -> Data Sync...
- Select the connection previously created for your Source Connection
- Choose a Quick Setup option to assist with configuration (YouTube API 3.0 List My Channels)
-
Modify the URL as needed (the URL may container {channelId} or {videoId} parameters that should be replaced with the correct values)
Refer to the YouTube API documentation for more information -
The Paging Strategy should be set to Bookmark/Token to allow DataZen to fetch all available records
- Token Param Name: pageToken
- Value Path: nextPageToken
- Make sure the Apply XML/JSON Transformation is checked
- Document Root Path: items
- To try the call, modify the Max Rows value if desired and click the preview link