You need the following information before you begin.

  • The client ID and client secret for the client application
  • The scope or scopes that define permissions for the client application

The Configuration Manager uses the authorization code grant to obtain access and refresh tokens from Google Cloud. The following steps describe how you can use the Configuration Manager to obtain access and refresh tokens. In addition, the Configuration Manager produces a connection URL that you can use in your application.

Note: You must allow popups in your browser to obtain access and refresh tokens with the Configuration Manager.
  1. Open the Configuration Manager by double-clicking the driver jar file. Alternately, from the command line, navigate to the directory containing your driver jar file, and then execute the following command:
    java -jar googleanalytics4.jar

    Step result: The Configuration Manager opens in your default web browser.

  2. Enter values for the required connection properties under the Connection tab.
    • Client ID
    • Client Secret
    • Scope

      The following scopes are the default scopes used by the driver.

      • View and download data:

        https://www.googleapis.com/auth/analytics

        https://www.googleapis.com/auth/analytics.readonly

      • View user permissions:

        https://www.googleapis.com/auth/analytics.manage.users.readonly

  3. Enter any additional values under the Connection tab, or other tabs, as desired.
  4. Retrieve access and refresh tokens:
    1. Click Fetch OAuth Token.
    2. If prompted, enter your Google credentials.
    3. Provide consent to allow the Configuration Manager to retrieve the tokens.
    4. The Access Token and Refresh Token fields populate with values retrieved from Google Cloud.
  5. Click Test Connect to verify connectivity and run SQL queries against the service.

Results:

The Access Token and Refresh Token fields contain access and refresh tokens. You can use these tokens to configure the driver and access Google Analytics resources.

The connection string in the Connection String field may be copied and used in your JDBC application to access Google Analytics resources.

Note: Not all the values in the resulting connection string may be required. However, the connection string can be copied directly into your JDBC application. The driver ignores any values that are not required.