Skip to content

Commit 736842d

Browse files
authored
Fix missing scopes for service account keys specified via GOOGLE_APPLICATION_CREDENTIALS (#448) (#449)
1 parent 9484044 commit 736842d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

dask_cloudprovider/gcp/instances.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,21 +657,24 @@ def __init__(self, service_account_credentials: Optional[dict[str, Any]] = None)
657657
self._compute = self.refresh_client()
658658

659659
def refresh_client(self):
660+
661+
scopes = ["https://www.googleapis.com/auth/cloud-platform"]
662+
660663
if self.service_account_credentials:
661664
import google.oauth2.service_account # google-auth
662665

663666
credentials = (
664667
google.oauth2.service_account.Credentials.from_service_account_info(
665668
self.service_account_credentials,
666-
scopes=["https://www.googleapis.com/auth/cloud-platform"],
669+
scopes=scopes,
667670
)
668671
)
669672
else:
670673
import google.auth
671674

672675
# Obtain Application Default Credentials (ADC)
673676
try:
674-
credentials, _ = google.auth.default()
677+
credentials, _ = google.auth.default(scopes)
675678
except google.auth.exceptions.DefaultCredentialsError as e:
676679
raise GCPCredentialsError() from e
677680

0 commit comments

Comments
 (0)