Skip to content

Commit c9cb608

Browse files
Format
1 parent 7e4f0c1 commit c9cb608

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/OAuthClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ private static byte[] sha256(byte[] input) {
191191
}
192192

193193
protected static String urlEncode(String urlBase, Map<String, String> params) {
194-
if (params.isEmpty()) {
194+
if (params == null || params.isEmpty()) {
195195
return urlBase;
196196
}
197197

@@ -217,6 +217,11 @@ private static String encodeParam(String value) {
217217
}
218218

219219
public Consent initiateConsent() throws MalformedURLException {
220+
if (authUrl == null) {
221+
throw new DatabricksException(
222+
"Authorization URL is not configured. OAuth endpoints may not be available.");
223+
}
224+
220225
String state = tokenUrlSafe(16);
221226
String verifier = tokenUrlSafe(32);
222227
byte[] digest = sha256(verifier.getBytes(StandardCharsets.UTF_8));

databricks-sdk-java/src/test/java/com/databricks/sdk/core/oauth/ExternalBrowserCredentialsProviderTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ void clientAndConsentTest() throws IOException {
2929
new FixtureServer.FixtureMapping.Builder()
3030
.validateMethod("GET")
3131
.validatePath("/oidc/.well-known/oauth-authorization-server")
32-
.withResponse("{\"token_endpoint\": \"tokenEndPointFromServer\"}", 200)
32+
.withResponse(
33+
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
34+
200)
3335
.build();
3436
try (FixtureServer fixtures = new FixtureServer()) {
3537
fixtures.with(fixture).with(fixture);
@@ -73,7 +75,9 @@ void clientAndConsentTestWithCustomRedirectUrl() throws IOException {
7375
new FixtureServer.FixtureMapping.Builder()
7476
.validateMethod("GET")
7577
.validatePath("/oidc/.well-known/oauth-authorization-server")
76-
.withResponse("{\"token_endpoint\": \"tokenEndPointFromServer\"}", 200)
78+
.withResponse(
79+
"{\"token_endpoint\": \"tokenEndPointFromServer\", \"authorization_endpoint\": \"authEndPointFromServer\"}",
80+
200)
7781
.build();
7882
try (FixtureServer fixtures = new FixtureServer()) {
7983
fixtures.with(fixture).with(fixture);

0 commit comments

Comments
 (0)