The CDATA connections in Infoworks allow users to connect to various sources, one such is Youtube Analytics. Connecting to Youtube Analytics to fetch the data requires OAuth authentication. The auth mechanism should be set in such a way that refresh of access token is done automatically. Please follow the below steps for the same. 


Instructions


  1. Set the JDBC URL as

    jdbc:youtubeanalytics:InitiateOAuth=GETANDREFRESH


  2. Add the email id of the youtube user as the username, Set the password to *.


  3. Please enable  Youtube Analytics API & Youtube Data API v3 from the following page

    https://console.cloud.google.com/apis/library/youtubeanalytics.googleapis.com?authuser=1
    https://console.cloud.google.com/apis/library/youtube.googleapis.com?authuser=1
  4. Obtain the Oauth2 credentials, client id, and client secret, from this page. If there are no credentials in the OAuth client id section, you can create one using "create credentials". (while creating credentials please add the redirect URI as: https://developers.google.com/oauthplayground )

    https://console.cloud.google.com/apis/credentials?pli=1
  5. Perform the following steps to obtain the OAuth refresh token and access token. 

    1. Visit: https://developers.google.com/oauthplayground/ 

    2. Fill the client id and secret obtained from step 4 in the highlighted fields under settings
    3. In the select & authorize APIs section select https://www.googleapis.com/auth/youtube.readonly under YouTube Analytics API v2 and click on authorize APIs.

    4. Now click on the exchange authorization code for tokens.

    5. Now in the right pane of the page, you will have the access token and the refresh token in the following format:

    6. {
        "access_token": "ya29.a0ARrdaM_XgrvIg65QYjlcpWCGCIzSzxE_DywzwcIu0VZbIJ5qPr-ljS59bD8E3Fmej0FQWhOheeoBri5-XBZw9PHTbNrCCfG5I5r4n3kL_mbVdGsvoh_l0yZaPZ5m14KWNGg6Ura2s4vNLMGrG_BRjsNg807l", 
        "scope": "https://www.googleapis.com/auth/youtube.readonly", 
        "token_type": "Bearer", 
        "expires_in": 3599, 
        "refresh_token": "1//04NwjjLHBJzAbCgYIARAAGAQSNwF-L9Ird1co4iKPsVWY6H1B-qaH9Z2WBZXZH6YwPYRmvzz-5gHdZlPT0GAGLVQErg5y1pwxSQg"
      }

  6. Now in the Infoworks UI pass the following as the additional connection parameters (Format specified here : KEY: VALUE)

    OAuthRefreshToken: your-access-token

    OAuthClientId: your-client-id

    OAuthClientSecret: your-client-secret

    InitiateOAuth: GETANDREFRESH

    OAuthRefreshToken: your-refresh-token