Skip to content

Commit 6d713fe

Browse files
committed
fix: update GDCH audience error message to be more descriptive
1 parent 571c9ac commit 6d713fe

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

oauth2_http/java/com/google/auth/oauth2/GdchCredentials.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static GdchCredentials fromPkcs8(String privateKeyPkcs8, GdchCredentials.Builder
250250
@ObsoleteApi("Use createWithGdchAudience(String) instead.")
251251
public GdchCredentials createWithGdchAudience(URI apiAudience) {
252252
Preconditions.checkNotNull(
253-
apiAudience, "Audience are not configured for GDCH service account credentials.");
253+
apiAudience, "Audience cannot be null or empty for GDCH service account credentials.");
254254
return this.toBuilder().setGdchAudience(apiAudience.toString()).build();
255255
}
256256

@@ -262,7 +262,7 @@ public GdchCredentials createWithGdchAudience(URI apiAudience) {
262262
public GdchCredentials createWithGdchAudience(String apiAudience) {
263263
if (Strings.isNullOrEmpty(apiAudience)) {
264264
throw new IllegalArgumentException(
265-
"Audience are not configured for GDCH service account credentials.");
265+
"Audience cannot be null or empty for GDCH service account credentials.");
266266
}
267267
return this.toBuilder().setGdchAudience(apiAudience).build();
268268
}
@@ -278,8 +278,8 @@ public GdchCredentials createWithGdchAudience(String apiAudience) {
278278
public AccessToken refreshAccessToken() throws IOException {
279279
Preconditions.checkNotNull(
280280
this.apiAudience,
281-
"Audience are not configured for GDCH service account. Specify the "
282-
+ "audience by calling createWithGDCHAudience.");
281+
"Audience cannot be null or empty for GDCH service account credentials. "
282+
+ "Specify the audience by calling createWithGdchAudience.");
283283

284284
JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
285285

oauth2_http/javatests/com/google/auth/oauth2/GdchCredentialsTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ void createWithGdchAudience_nullApiAudience() throws IOException {
525525
assertThrows(
526526
IllegalArgumentException.class,
527527
() -> credentials.createWithGdchAudience((String) null));
528-
assertTrue(ex.getMessage().contains("Audience are not configured for GDCH service account"));
528+
assertTrue(ex.getMessage().contains("Audience cannot be null or empty for GDCH service account"));
529529
}
530530

531531
@Test
@@ -545,7 +545,7 @@ void createWithGdchAudience_emptyApiAudience() throws IOException {
545545
assertThrows(
546546
IllegalArgumentException.class,
547547
() -> credentials.createWithGdchAudience(""));
548-
assertTrue(ex.getMessage().contains("Audience are not configured for GDCH service account"));
548+
assertTrue(ex.getMessage().contains("Audience cannot be null or empty for GDCH service account"));
549549
}
550550

551551
@Test
@@ -664,8 +664,8 @@ void refreshAccessToken_nullApiAudience() throws IOException {
664664
assertTrue(
665665
ex.getMessage()
666666
.contains(
667-
"Audience are not configured for GDCH service account. Specify the "
668-
+ "audience by calling createWithGDCHAudience"));
667+
"Audience cannot be null or empty for GDCH service account credentials. "
668+
+ "Specify the audience by calling createWithGdchAudience"));
669669
}
670670
}
671671

0 commit comments

Comments
 (0)