Google Analytics
Establishing a Connection
Authenticate via OAuth Authentication
Use the OAuth authentication standard to connect to Google 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.
Create an OAuth App for User Account Authentication
Instead of connecting with the provider's embedded credentials, you can register an app to obtain the OAuthClientId and OAuthClientSecret.
Follow the procedure below to register an app and obtain the OAuthClientId and OAuthClientSecret.
Log into the Google API Console and open a project. Select the API Manager from the main menu.
In the user consent flow, click Credentials -> Create Credentials -> OAuth Client Id. Click Other. After creating the app, the OAuthClientId and OAuthClientSecret are displayed.
Click Library -> Analytics API -> Enable API.
After setting the following, you are ready to connect:
OAuthClientId: Set this to the client Id assigned when you registered your app.
OAuthClientSecret: Set this to the client secret assigned when you registered your app.
InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
Profile: Set this to the Google Analytics profile or view you want to connect to. This value can be retrieved from the Profiles table. If this is not specified, the first Profile returned will be used.
When you connect the provider opens the OAuth endpoint in your default browser. Log in and grant permissions to the application. The provider then completes the OAuth process:
Extracts the access token from the callback URL and authenticates requests.
Refreshes the access token when it expires.
Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
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.
Log into the Google API Console and open a project. Select the API Manager from the main menu.
Click Create Credentials -> Service Account Key.
In the Service Account menu, select New Service Account or select an existing service account.
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.
In the Key Type section, select the P12 key type.
Create the app to download the key pair. The private key's password is displayed: Set this in OAuthJWTCertPassword.
In the service accounts section, click Manage Service Accounts and set OAuthJWTIssuer to the email address displayed in the service account Id field.
Click Library -> Analytics API -> Enable API.
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.
You can then connect to Google Analytics data that the service account has permission to access.
After setting the following connection properties, you are ready to connect:
InitiateOAuth: Set this to GETANDREFRESH.
OAuthJWTCertType: Set this to "PFXFile".
OAuthJWTCert: Set this to the path to the .p12 file you generated.
OAuthJWTCertPassword: Set this to the password of the .pem file.
OAuthJWTCertSubject: Set this to "*" to pick the first certificate in the certificate store.
OAuthJWTSubject (optional): Set this 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.
Profile: Set this to the Google Analytics profile or view you want to connect to. This value can be retrieved from the Profiles table. If this is not specified, the first Profile returned will be used.
When you connect the provider completes the OAuth flow for a service account.
Creates and signs the JWT with the claim set required by the provider.
Exchanges the JWT for the access token.
Saves OAuth values in OAuthSettingsLocation to be persisted across connections.
Submits the JWT for a new access token when the token expires.
Last updated