Commit b50289c
authored
Pass Account Id to OAuthClient in External Browser Authentication. (#479)
## What changes are proposed in this pull request?
Users with membership in multiple Databricks accounts are sent to an
incorrect authorization URL with the external-browser auth type in the
Java SDK. Because the new DatabricksConfig created in the OAuthClient
doesn't include the account ID so getOidcEndpoints returns endpoints
with no account ID in the path. Which redirects it to the default
account and not the account that was specified in the intial Config.
## How is this tested?
Manually tested that it is not the case anymore using the below code.
```
public static void main(String[] args) {
DatabricksConfig config = new DatabricksConfig()
.setAuthType("external-browser")
.setHost("https://accounts.cloud.databricks.com")
.setAccountId("<redacted>")
.setScopes(List.of("all-apis", "offline_access"))
.setOAuthRedirectUrl("http://localhost:8022");
AccountClient acct = new AccountClient(config);
for (Workspace w: acct.workspaces().list()){
System.out.println(w.getWorkspaceName());
}
}
```
The current code is not flexible enough to have unit tests in it and
needs a bigger refactor. So, unit tests are not added.
NO_CHANGELOG=true1 parent f0582e8 commit b50289c
File tree
2 files changed
+9
-1
lines changed- databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth
2 files changed
+9
-1
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
92 | 98 | | |
93 | 99 | | |
94 | 100 | | |
95 | | - | |
| 101 | + | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
0 commit comments