fix: disable self signed jwt for domain wide delegation (#873)
diff --git a/google/oauth2/service_account.py b/google/oauth2/service_account.py
index 8f18f26..ecaac03 100644
--- a/google/oauth2/service_account.py
+++ b/google/oauth2/service_account.py
@@ -399,7 +399,9 @@
@_helpers.copy_docstring(credentials.Credentials)
def refresh(self, request):
- if self._jwt_credentials is not None:
+ # Since domain wide delegation doesn't work with self signed JWT. If
+ # subject exists, then we should not use self signed JWT.
+ if self._subject is None and self._jwt_credentials is not None:
self._jwt_credentials.refresh(request)
self.token = self._jwt_credentials.token
self.expiry = self._jwt_credentials.expiry