summaryrefslogtreecommitdiffstats
path: root/contrib/python/google-auth/py3/google/auth/_default.py
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2025-04-29 13:13:02 +0300
committerrobot-piglet <[email protected]>2025-04-29 13:30:37 +0300
commit43c48235ff779855489561438e0ba08bd8dfb4fc (patch)
tree38288f51b582424c1fc554aab78a5e27f303d72a /contrib/python/google-auth/py3/google/auth/_default.py
parent46634855c4eebcbf9416afe1bd0448058aa40373 (diff)
Intermediate changes
commit_hash:8152cafb3d167774615b4df5bf4470b6269e88a7
Diffstat (limited to 'contrib/python/google-auth/py3/google/auth/_default.py')
-rw-r--r--contrib/python/google-auth/py3/google/auth/_default.py38
1 files changed, 2 insertions, 36 deletions
diff --git a/contrib/python/google-auth/py3/google/auth/_default.py b/contrib/python/google-auth/py3/google/auth/_default.py
index 1234fb25d78..cf0cdd77298 100644
--- a/contrib/python/google-auth/py3/google/auth/_default.py
+++ b/contrib/python/google-auth/py3/google/auth/_default.py
@@ -484,42 +484,8 @@ def _get_impersonated_service_account_credentials(filename, info, scopes):
from google.auth import impersonated_credentials
try:
- source_credentials_info = info.get("source_credentials")
- source_credentials_type = source_credentials_info.get("type")
- if source_credentials_type == _AUTHORIZED_USER_TYPE:
- source_credentials, _ = _get_authorized_user_credentials(
- filename, source_credentials_info
- )
- elif source_credentials_type == _SERVICE_ACCOUNT_TYPE:
- source_credentials, _ = _get_service_account_credentials(
- filename, source_credentials_info
- )
- elif source_credentials_type == _EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE:
- source_credentials, _ = _get_external_account_authorized_user_credentials(
- filename, source_credentials_info
- )
- else:
- raise exceptions.InvalidType(
- "source credential of type {} is not supported.".format(
- source_credentials_type
- )
- )
- impersonation_url = info.get("service_account_impersonation_url")
- start_index = impersonation_url.rfind("/")
- end_index = impersonation_url.find(":generateAccessToken")
- if start_index == -1 or end_index == -1 or start_index > end_index:
- raise exceptions.InvalidValue(
- "Cannot extract target principal from {}".format(impersonation_url)
- )
- target_principal = impersonation_url[start_index + 1 : end_index]
- delegates = info.get("delegates")
- quota_project_id = info.get("quota_project_id")
- credentials = impersonated_credentials.Credentials(
- source_credentials,
- target_principal,
- scopes,
- delegates,
- quota_project_id=quota_project_id,
+ credentials = impersonated_credentials.Credentials.from_impersonated_service_account_info(
+ info, scopes=scopes
)
except ValueError as caught_exc:
msg = "Failed to load impersonated service account credentials from {}".format(