Passing the connection URL
- Last Updated: June 12, 2023
- 1 minute read
- DataDirect Connectors
- JDBC
- Documentation
After setting the CLASSPATH, the required connection information needs to be passed in the form of a connection URL. The following example includes the properties required for connecting with OAuth 2.0 authentication with a refresh token.
Connection URL Syntax
The connection URL takes the following form:
jdbc:datadirect:googleanalytics4:AddTables='{myTableDefinitionString}';
ClientID=client_id.apps.googleusercontent.com;ClientSecret=client_secret;
RefreshToken=refresh_token;Scope=scope;[property=value[;...]];
where:
- myTableDefinitionString
- Specifies a JSON string that defines custom tables, including dimensions and metrics, that
appear in the Google Analytics 4 schema. For example:
'{"TestTable":["sessions","totalUsers","_browser","_sessionSource"]}'.Note: You can generate a value for the property using the Configure Logical Schema tool in the Configuration Manager. See Generating connection URLs with the Configuration Manager for details.
- client_id
- specifies the client ID for your application when authenticating to Google Analytics with OAuth 2.0 enabled.
- client_secret
-
specifies the client secret for your application when authenticating to Google Analytics with OAuth 2.0 enabled.
Important: The client secret is a confidential value used to authenticate the application to the service. To prevent unauthorized access, this value must be securely maintained.
- refresh_token
-
specifies the refresh token used to either request a new access token or renew an expired access token for OAuth 2.0 implementations.Important: The refresh token is a confidential value used to authenticate to the service. To prevent unauthorized access, this value must be securely maintained.
- scope
-
(Optional) specifies a space-separated list of OAuth scopes that limit the permissions granted by an access token. The default is:
https://www.googleapis.com/auth/analytics.manage.users.readonly https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/analytics
- property=value
- specifies connection property settings. Multiple properties are separated by a semi-colon.
Connection URL Examples:
Connection conn = DriverManager.getConnection
(jdbc:datadirect:googleanalytics4:
AddTables='{"TestTable":["sessions","totalUsers","_browser","_sessionSource"]}';
ClientID=ab123c45-def6-7g89-gh1i-m2345no67891.apps.googleusercontent.com;
ClientSecret=12a3=bCD/EfGh4Ijk+Lm5P67qR8s=//TuV+WXy1Zabcd;
RefreshToken=1//12a3=bCD/EfGh4Ijk+Lgd8g-44tk3c527831;Scope=scope;
[property=value[;...]];);