cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How can we customize the access token expiry duration?

Balram-snaplogi
New Contributor

Hi,

I am using OAuth machine-to-machine (M2M) authentication. I created a service principal and wrote a Java application that allows me to connect to the Databricks warehouse. My question is regarding the code below:

String url = "jdbc:databricks://<server-hostname>:443";
Properties p = new java.util.Properties();
p.put("httpPath", "<http-path>");
p.put("AuthMech", "11");
p.put("Auth_Flow", "1");
p.put("OAuth2ClientId", "<service-principal-application-id>");
p.put("OAuth2Secret", "<service-principal-oauth-secret>");
Connection conn = DriverManager.getConnection(url, p);

I only provide the client ID and secret, and the rest is handled by the driver, such as generating the access token internally. According to the documentation, the access token expires after 1 hour. If my application runs continuously for more than 1 hour, will the driver automatically handle token refresh once the current token expires? Alternatively, is there a way to customize the access token expiration duration when creating the service principal?

thanks



1 REPLY 1

Walter_C
Databricks Employee
Databricks Employee

I would say that your token should be manually refreshed as mentioned in the following statement in docs:

Databricks tools and SDKs that implement the Databricks client unified authentication standard will automatically generate, refresh, and use Databricks OAuth access tokens on your behalf as needed for OAuth M2M authentication.

Databricks recommends using client unified authentication, however if you must manually generate, refresh, or use Databricks OAuth access tokens, follow the instructions in this section.

As on the connection string you are not being requested to generate the token this should means it is done on behalf.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group