Skip to content

Commit 88891cc

Browse files
authored
fix: auth fetch token from default endpoint (#1779)
1 parent 0be91e2 commit 88891cc

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

google/auth/compute_engine/credentials.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ def refresh(self, request):
124124
scopes = self._scopes if self._scopes is not None else self._default_scopes
125125
try:
126126
self._retrieve_info(request)
127+
# Always fetch token with default service account email.
127128
self.token, self.expiry = _metadata.get_service_account_token(
128-
request, service_account=self._service_account_email, scopes=scopes
129+
request, service_account="default", scopes=scopes
129130
)
130131
except exceptions.TransportError as caught_exc:
131132
new_exc = exceptions.RefreshError(caught_exc)

tests/compute_engine/test_credentials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ def test_with_target_audience_integration(self):
501501
responses.add(
502502
responses.GET,
503503
"http://metadata.google.internal/computeMetadata/v1/instance/"
504-
"service-accounts/service-account@example.com/token",
504+
"service-accounts/default/token",
505505
status=200,
506506
content_type="application/json",
507507
json={
@@ -659,7 +659,7 @@ def test_with_quota_project_integration(self):
659659
responses.add(
660660
responses.GET,
661661
"http://metadata.google.internal/computeMetadata/v1/instance/"
662-
"service-accounts/service-account@example.com/token",
662+
"service-accounts/default/token",
663663
status=200,
664664
content_type="application/json",
665665
json={

0 commit comments

Comments
 (0)