Configuring a Connection
After Installing the Connector you can connect and create a Data Source for data in Lakebase.
Setting Up a Data Source
Complete the following steps to connect to the data:
- Under Connect | To a Server, click More....
- Select the data source called Lakebase by CData.
- Enter the information required for the connection.
- Click Sign In.
- If necessary, select a Database and Schema to discover what tables and views are available.
Using the Connection Builder
The connector makes the most common connection properties available directly in Tableau. However, it can be difficult to use if you need to use more advanced settings or need to troubleshoot connection issues. The connector includes a separate connection builder that allows you to create and test connections outside of Tableau.
There are two ways to access the connection builder:
- On Windows, use a shortcut called Connection Builder in the Start menu, under the CData Tableau Connector for Lakebase folder.
- You can also start the connection builder by going to the driver install directory and running the .jar file in the lib directory.
In the connection builder, you can set values for connection properties and click Test Connection to validate that they work. You can also use the Copy to Clipboard button to save the connection string. This connection string can be given to the Connection String option included in the connector connection window in Tableau.
Connecting to Lakebase
To connect to Lakebase, set these properties:- DatabricksInstance: The Databricks instance or server hostname, provided in the format instance-abcdef12-3456-7890-abcd-abcdef123456.database.cloud.databricks.com .
- Server: The host name or IP address of the server hosting the Lakebase database.
- Port (optional): The port of the server hosting the Lakebase database, set to 5432 by default.
- Database (optional): The database to connect to after authenticating to the Lakebase Server, set to the authenticating user's default database by default.
Authentication Schemes for Lakebase
Lakebase supports two types of OAuth-based authentication schemes for calling workspace-level APIs: OAuthClient and OAuthPKCE.
OAuthClient
OAuthClient uses the OAuth client credentials grant type. This authentication scheme requires you to perform additional configuration on your service principal in order to connect, as described in Setting Up OAuthClient Authentication.Authentication is handled via the OAuth Client Credentials flow. This flow does not involve direct user authentication; rather, it uses credentials that apply only to the application itself. The CData Tableau Connector for Lakebase uses the service principal itself to authenticate with the associated permissions being defined in the service principal.
Since no embedded OAuth credentials are provided, specifying the OAuthClient authentication scheme requires you to perform extra configuration of your service principal, as described in Setting Up OAuthClient Authentication.
Set these configuration parameters:
- AuthScheme: OAuthClient.
- OAuthClientId: The client ID (also known as the consumer key) that was assigned when you configured the service principal. This ID is required to identify the application to the OAuth authorization server during authentication.
- OAuthClientSecret: The client secret (also known as the application secret or consumer secret) that was assigned when you configured the service principal. This confidential value is used to authenticate the application to the OAuth authorization server.
OAuthPKCE
OAuthPKCE uses the OAuth code grant type with PKCE (Proof Key for Code Exchange) to guard against cross-site request forgery and authorization code injection attacks.In this authentication scheme, authentication is handled via the use of a temporary code that the client exchanges for an access token. The code itself is obtained from the authorization server, where the user can see what information the client is requesting, and can either approve or deny the request.
Set these configuration parameters:
- AuthScheme: OAuthPKCE.
- User: The authenticating user's user ID.
Authenticating to Lakebase
Once you have set the configuration parameters required to connect to Lakebase, and the configuration parameters required for your chosen form of authentication, you can authenticate to Lakebase as described in the following sections.
Desktop Applications
The first time you authenticate to Lakebase from a desktop application you must set InitiateOAuth twice in the course of the OAuth flow:
- At initial login, you must set InitiateOAuth to GETANDREFRESH. This launches the login page and saves tokens.
- Once you have obtained valid access and refresh tokens, you can re-set InitiateOAuth to REFRESH. This reuses stored tokens without prompting the user again, which can be useful on unattended machines.
After authentication, tokens are saved to OAuthSettingsLocation. These values persist across sessions and are used to automatically refresh the access token when it expires. This means that upon subsequent connections you will not need to log in again.
Headless Machines
Headless environments like CI/CD pipelines, background services, or server-based integrations do not have an interactive browser. To authenticate using OAuthClient, you must complete the OAuth flow on a separate device with a browser and transfer the authentication result to the headless system.
Note: The following procedures are meant for use with the OAuthPKCE authscheme. Since the OAuthClient authscheme does not require browser interaction, it can make use of InitiateOAuth=GETANDREFRESH on a headless machine as well.
Setup option:
- Transfer an OAuth settings file: Authenticate on another device, then copy the stored token file to the headless environment.
Transferring OAuth Settings
- On a device with a browser, connect using the instructions in the Desktop Applications section.
After connecting, tokens are saved to the file path in OAuthSettingsLocation. The default filename is OAuthSettings.txt.
- On the headless machine:
- Copy the OAuth settings file to the machine.
- Set the following properties:
- InitiateOAuth: REFRESH
- OAuthSettingsLocation: Make sure this location grants read and write permissions to the driver to enable the automatic refreshing of the access token.
After setup, the driver uses the stored tokens to refresh the access token automatically. No browser or manual login is required.
Next Step
See Using the Connector to create data visualizations.