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 @@ -564,7 +564,7 @@ public static ServiceAccountCredentials fromStream(
/** Returns whether the scopes are empty, meaning createScoped must be called before use. */
@Override
public boolean createScopedRequired() {
return scopes.isEmpty();
return scopes.isEmpty() && defaultScopes.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,14 +488,23 @@ public void createScopedRequired_emptyScopes() throws IOException {
}

@Test
public void createScopedRequired_nonEmptyScopes_false() throws IOException {
public void createScopedRequired_nonEmptyScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, SCOPES);

assertFalse(credentials.createScopedRequired());
}

@Test
public void createScopedRequired_nonEmptyDefaultScopes() throws IOException {
GoogleCredentials credentials =
ServiceAccountCredentials.fromPkcs8(
CLIENT_ID, CLIENT_EMAIL, PRIVATE_KEY_PKCS8, PRIVATE_KEY_ID, null, SCOPES);

assertFalse(credentials.createScopedRequired());
}

@Test
public void fromJSON_getProjectId() throws IOException {
MockTokenServerTransportFactory transportFactory = new MockTokenServerTransportFactory();
Expand Down