databricks-sdk-java
databricks-sdk-java copied to clipboard
Fix U2M OAuth flows in Azure
What changes are proposed in this pull request?
This PR fixes some issues affecting the end-to-end workflow using External Browser auth in Azure. In addition to the base PR by @renaudhartert-db:
- This corrects the default redirect URL for the Databricks CLI to http://localhost:8020, matching the Go SDK.
- This fixes OAuth token caching to include the actual scopes requested in the hash (otherwise, if no scopes are requested, that is treated as
nulltoday, causing an NPE). - This removes legacy Azure-specific handling for U2M Auth, where we requested the 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/user_impersonation permission. This is not needed anymore, since we login with the Databricks CLI App by default.
- This fixes serialization of query parameters, using the standard UrlEncoder instead of the very approximate version replacing spaces with %20.
- This changes the default scopes requested to be
offline_accessandall-apis, matching the defaults for the Go SDK & CLI.
How is this tested?
I wrote a demo app using U2M OAuth to authenticate and make an API request:
package com.databricks.sdk.demo;
import com.databricks.sdk.WorkspaceClient;
import com.databricks.sdk.core.DatabricksConfig;
public class App {
public final static void main(String[] args) {
DatabricksConfig config = new DatabricksConfig()
.setHost("https://<azure workspace host>")
.setAuthType("external-browser");
WorkspaceClient client = new WorkspaceClient(config);
System.out.println(client.currentUser().me());
}
}
This succeeded.
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. If this is not necessary for your PR, please include the following in your PR description: NO_CHANGELOG=true and rerun the job.