Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,12 @@ public static ServiceAccountCredentials fromStream(
fileType, SERVICE_ACCOUNT_FILE_TYPE));
}

/** Returns whether the scopes are empty, meaning createScoped must be called before use. */
@Override
public boolean createScopedRequired() {
return scopes.isEmpty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think without having defaultScopes.isEmpty() here as well, the Client Library for Storage will never use self-signed JWTs. And there may be more APIs like this.

This can be fixed in a future PR, however.

}

/**
* Refreshes the OAuth2 access token by getting a new access token using a JSON Web Token (JWT).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,12 @@ public void createdScoped_defaultScopes() throws IOException {
}

@Test
public void createScopedRequired_emptyScopes_false() throws IOException {
public void createScopedRequired_emptyScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, EMPTY_SCOPES);

assertFalse(credentials.createScopedRequired());
assertTrue(credentials.createScopedRequired());
}

@Test
Expand Down