Skip to content

Commit 0614482

Browse files
fix: fix service account credentials createScopedRequired (#601)
* fix: fix service account credentials createScopedRequired * Update oauth2_http/javatests/com/google/auth/oauth2/ServiceAccountCredentialsTest.java
1 parent 31ebe6e commit 0614482

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,12 @@ public static ServiceAccountCredentials fromStream(
561561
fileType, SERVICE_ACCOUNT_FILE_TYPE));
562562
}
563563

564+
/** Returns whether the scopes are empty, meaning createScoped must be called before use. */
565+
@Override
566+
public boolean createScopedRequired() {
567+
return scopes.isEmpty();
568+
}
569+
564570
/**
565571
* Refreshes the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).
566572
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,12 @@ public void createdScoped_defaultScopes() throws IOException {
479479
}
480480

481481
@Test
482-
public void createScopedRequired_emptyScopes_false() throws IOException {
482+
public void createScopedRequired_emptyScopes() throws IOException {
483483
GoogleCredentials credentials =
484484
ServiceAccountCredentials.fromPkcs8(
485485
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, EMPTY_SCOPES);
486486

487-
assertFalse(credentials.createScopedRequired());
487+
assertTrue(credentials.createScopedRequired());
488488
}
489489

490490
@Test

0 commit comments

Comments
 (0)