Authentication settings for the Databricks ODBC Driver
This article describes how to configure Databricks authentication settings for the Databricks ODBC Driver.
The Databricks ODBC Driver supports the following Databricks authentication types:
Note
Basic authentication using a Databricks username and password reached end of life on July 10, 2024. See End of life for Databricks-managed passwords.
Databricks personal access token
To create a Databricks personal access token, do the following:
In your Databricks workspace, click your Databricks username in the top bar, and then select Settings from the drop down.
Click Developer.
Next to Access tokens, click Manage.
Click Generate new token.
(Optional) Enter a comment that helps you to identify this token in the future, and change the token’s default lifetime of 90 days. To create a token with no lifetime (not recommended), leave the Lifetime (days) box empty (blank).
Click Generate.
Copy the displayed token to a secure location, and then click Done.
Note
Be sure to save the copied token in a secure location. Do not share your copied token with others. If you lose the copied token, you cannot regenerate that exact same token. Instead, you must repeat this procedure to create a new token. If you lose the copied token, or you believe that the token has been compromised, Databricks strongly recommends that you immediately delete that token from your workspace by clicking the trash can (Revoke) icon next to the token on the Access tokens page.
If you are not able to create or use tokens in your workspace, this might be because your workspace administrator has disabled tokens or has not given you permission to create or use tokens. See your workspace administrator or the following topics:
To authenticate using a Databricks personal access token, add the following configurations to your compute settings and any special or advanced driver capability settings:
Setting |
Value |
---|---|
|
3 |
|
|
|
The Databricks personal access token for your workspace user |
To create a DSN for non-Windows systems, use the following format:
[Databricks]
Driver=<path-to-driver>
Host=<server-hostname>
Port=443
HTTPPath=<http-path>
SSL=1
ThriftTransport=2
AuthMech=3
UID=token
PWD=<personal-access-token>
To create a DSN-less connection string, use the following format. Line breaks have been added for readability. The string must not contain these line breaks:
Driver=<path-to-driver>;
Host=<server-hostname>;
Port=443;
HTTPPath=<http-path>;
SSL=1;
ThriftTransport=2;
AuthMech=3;
UID=token;
PWD=<personal-access-token>
To get the value for
<path-to-driver>
, see Download and install the Databricks ODBC Driver.To get the values for
<server-hostname>
and<http-path>
, see Compute settings for the Databricks ODBC Driver.You can also add special or advanced driver capability settings.
OAuth 2.0 tokens
ODBC driver 2.7.5 and above supports an OAuth 2.0 token for a Databricks user or service principal. This is also known as OAuth 2.0 token pass-through authentication.
To create an OAuth 2.0 token for token pass-through authentication, do the following:
For a user, you can use the Databricks CLI to generate the OAuth 2.0 token by initiating the OAuth U2M process, and then get the generated OAuth 2.0 token by running the
databricks auth token
command. See OAuth user-to-machine (U2M) authentication. OAuth 2.0 tokens have a default lifetime of 1 hour. To generate a new OAuth 2.0 token, repeat this process.For a service principal, follow Steps 1-3 in Manually generate and use access tokens for OAuth M2M authentication. Make a note of the service principal’s OAuth
access_token
value. OAuth 2.0 tokens have a default lifetime of 1 hour. To generate a new OAuth 2.0 token, repeat this process.
To authenticate using OAuth 2.0 token pass-through authentication, add the following configurations to your compute settings and any special or advanced driver capability settings:
Setting |
Value |
---|---|
|
11 |
|
0 |
|
The OAuth 2.0 token |
To create a DSN for non-Windows systems, use the following format:
[Databricks]
Driver=<path-to-driver>
Host=<server-hostname>
Port=443
HTTPPath=<http-path>
SSL=1
ThriftTransport=2
AuthMech=11
Auth_Flow=0
Auth_AccessToken=<oauth-token>
To create a DSN-less connection string, use the following format. Line breaks have been added for readability. The string must not contain these line breaks:
Driver=<path-to-driver>;
Host=<server-hostname>;
Port=443;
HTTPPath=<http-path>;
SSL=1;
ThriftTransport=2;
AuthMech=11;
Auth_Flow=0;
Auth_AccessToken=<oauth-token>
To get the value for
<path-to-driver>
, see Download and install the Databricks ODBC Driver.To get the values for
<server-hostname>
and<http-path>
, see Compute settings for the Databricks ODBC Driver.You can also add special or advanced driver capability settings.
For more information, see the Token Pass-through
sections in the Databricks ODBC Driver Guide.
Databricks OAuth user-to-machine (U2M) authentication
ODBC driver 2.8.2 and above supports OAuth user-to-machine (U2M) authentication for a Databricks user. This is also known as OAuth 2.0 browser-based authentication.
OAuth U2M or OAuth 2.0 browser-based authentication has no prerequisites. OAuth 2.0 tokens have a default lifetime of 1 hour. OAuth U2M or OAuth 2.0 browser-based authentication should refresh expired OAuth 2.0 tokens for you automatically.
Note
OAuth U2M or OAuth 2.0 browser-based authentication works only with applications that run locally. It does not work with server-based or cloud-based applications.
To authenticate using OAuth user-to-machine (U2M) or OAuth 2.0 browser-based authentication, add the following configurations to your compute settings and any special or advanced driver capability settings:
Setting |
Value |
---|---|
|
11 |
|
2 |
|
A password of your choice. The driver uses this key for refresh token encryption. |
|
|
|
|
|
|
To create a DSN for non-Windows systems, use the following format:
[Databricks]
Driver=<path-to-driver>
Host=<server-hostname>
Port=443
HTTPPath=<http-path>
SSL=1
ThriftTransport=2
AuthMech=11
Auth_Flow=2
PWD=<password>
To create a DSN-less connection string, use the following format. Line breaks have been added for readability. The string must not contain these line breaks:
Driver=<path-to-driver>;
Host=<server-hostname>;
Port=443;
HTTPPath=<http-path>;
SSL=1;
ThriftTransport=2;
AuthMech=11;
Auth_Flow=2;
PWD=<password>
To get the value for
<path-to-driver>
, see Download and install the Databricks ODBC Driver.To get the values for
<server-hostname>
and<http-path>
, see Compute settings for the Databricks ODBC Driver.You can also add special or advanced driver capability settings.
For more information, see the Browser Based
sections in the Databricks ODBC Driver Guide.
OAuth machine-to-machine (M2M) authentication
ODBC driver supports OAuth machine-to-machine (M2M) authentication for a Databricks service principal. This is also known as OAuth 2.0 client credentials authentication.
To configure OAuth M2M or OAuth 2.0 client credentials authentication, do the following:
Create a Databricks service principal in your Databricks workspace, and create an OAuth secret for that service principal.
To create the service principal and its OAuth secret, see Authenticate access to Databricks with a service principal using OAuth (OAuth M2M). Make a note of the service principal’s UUID or Application ID value, and the Secret value for the service principal’s OAuth secret.
Give the service principal access to your cluster or warehouse. See Compute permissions or Manage a SQL warehouse.
To authenticate using OAuth machine-to-machine (M2M) or OAuth 2.0 client credentials authentication, add the following configurations to your compute settings and any special or advanced driver capability settings:
Setting |
Value |
---|---|
|
11 |
|
1 |
|
The service principal’s UUID/Application ID value. |
|
The service principal’s OAuth Secret value. |
|
|
To create a DSN for non-Windows systems, use the following format:
[Databricks]
Driver=<path-to-driver>
Host=<server-hostname>
Port=443
HTTPPath=<http-path>
SSL=1
ThriftTransport=2
AuthMech=11
Auth_Flow=1
Auth_Client_ID=<service-principal-application-ID>
Auth_Client_Secret=<service-principal-secret>
Auth_Scope=all-apis
To create a DSN-less connection string, use the following format. Line breaks have been added for readability. The string must not contain these line breaks:
Driver=<path-to-driver>;
Host=<server-hostname>;
Port=443;
HTTPPath=<http-path>;
SSL=1;
ThriftTransport=2;
AuthMech=11;
Auth_Flow=1;
Auth_Client_ID=<service-principal-application-ID>;
Auth_Client_Secret=<service-principal-secret>;
Auth_Scope=all-apis
To get the value for
<path-to-driver>
, see Download and install the Databricks ODBC Driver.To get the values for
<server-hostname>
and<http-path>
, see Compute settings for the Databricks ODBC Driver.You can also add special or advanced driver capability settings.
For more information, see the Client Credentials
sections in the Databricks ODBC Driver Guide.