Youtube Analytics

Authenticate via OAuth Authentication

Use the OAuth authentication standard to connect to YouTube Analytics. You can authenticate with a user account or with a service account. A service account is required to grant organization-wide access scopes to the provider. The provider facilitates these authentication flows as described below.

Authenticate with a User Account

Create an OAuth App for User Account Authentication

  1. Log into the Google API Console and open a project. Select the API Manager from the main menu.

  2. In the user consent flow, click Credentials -> Create Credentials -> OAuth Client Id. Click Other. After creating the app, the OAuthClientId and OAuthClientSecret are displayed.

  3. Click Library -> YouTube Analytics API -> Enable API.

Authenticate with a Service Account

Service accounts have silent authentication, without user authentication in the browser. You can also use a service account to delegate enterprise-wide access scopes to the provider.

Create an OAuth App for Service Account Authentication

Follow the steps below to create an OAuth application and generate a private key. You will then authorize the service account.

  1. Log into the Google API Console and open a project. Select the API Manager from the main menu.

  2. Click Create Credentials -> Service Account Key.

  3. In the Service Account menu, select New Service Account or select an existing service account.

  4. If you are creating a new service account, additionally select one or more roles. You can assign primitive roles at the project level in the IAM and Admin section; other roles enable you to further customize access to Google APIs.

  5. In the Key Type section, select the P12 key type.

  6. Create the app to download the key pair. The private key's password is displayed: Set this in OAuthJWTCertPassword.

  7. In the service accounts section, click Manage Service Accounts and set OAuthJWTIssuer to the email address displayed in the service account Id field.

  8. Click Library -> YouTube Analytics API -> Enable API

After setting the following connection properties, you are ready to connect:

  • InitiateOAuth: Set to GETANDREFRESH.

  • OAuthClientId: Set to the Client Id in your app settings.

  • OAuthClientSecret: Set to the Client Secret in your app settings.

  • OAuthJWTCertType: Set to "PEMKEY_FILE".

  • OAuthJWTCert: Set to the path to the .pem file you generated.

  • OAuthJWTCertPassword: Set to the password of the .pem file.

  • OAuthJWTCertSubject: Set to "*" to pick the first certificate in the certificate store.

  • OAuthJWTSubject: Set to the email address of the user for whom the application is requesting delegate access. Note that delegate access must be granted by an administrator.

  • ChannelId: Set to the Id of a YouTube channel. If not specified, data is returned for the authenticated user's channel.

  • ContentOwnerId: Set if you want to generate content owner reports.

When you connect the provider completes the OAuth flow for a service account.

  1. Creates and signs the JWT with the claim set required by the provider.

  2. Exchanges the JWT for the access token.

  3. Saves OAuth values in OAuthSettingsLocation to be persisted across connections.

  4. Submits the JWT for a new access token when the token expires.

Last updated