Skip to content

Commit 3d747e7

Browse files
matthew29tangcopybara-github
authored andcommitted
fix: Add default auth scope
PiperOrigin-RevId: 769811851
1 parent eac1de0 commit 3d747e7

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

google/cloud/aiplatform/initializer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def _set_project_as_env_var_or_google_auth_default(self):
9494
)
9595
if project_number:
9696
if not self._credentials:
97-
credentials, _ = google.auth.default()
97+
credentials, _ = google.auth.default(
98+
scopes=constants.DEFAULT_AUTHED_SCOPES
99+
)
98100
self._credentials = credentials
99101
# Try to convert project number to project ID which is more readable.
100102
try:
@@ -114,7 +116,7 @@ def _set_project_as_env_var_or_google_auth_default(self):
114116
self._project = project
115117

116118
if not self._credentials and not self._api_key:
117-
credentials, _ = google.auth.default()
119+
credentials, _ = google.auth.default(scopes=constants.DEFAULT_AUTHED_SCOPES)
118120
self._credentials = credentials
119121

120122
def __init__(self):

tests/unit/aiplatform/test_initializer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_init_project_sets_project(self):
6565
assert initializer.global_config.project == _TEST_PROJECT
6666

6767
def test_not_init_project_gets_default_project(self, monkeypatch):
68-
def mock_auth_default():
68+
def mock_auth_default(scopes=None):
6969
return None, _TEST_PROJECT
7070

7171
monkeypatch.setattr(google.auth, "default", mock_auth_default)

0 commit comments

Comments
 (0)