8282from google .oauth2 import _client
8383
8484_DEFAULT_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds
85- _DEFAULT_UNIVERSE_DOMAIN = "googleapis.com"
8685_GOOGLE_OAUTH2_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
8786
8887
@@ -139,7 +138,7 @@ def __init__(
139138 quota_project_id = None ,
140139 additional_claims = None ,
141140 always_use_jwt_access = False ,
142- universe_domain = _DEFAULT_UNIVERSE_DOMAIN ,
141+ universe_domain = credentials . DEFAULT_UNIVERSE_DOMAIN ,
143142 trust_boundary = None ,
144143 ):
145144 """
@@ -182,9 +181,9 @@ def __init__(
182181 self ._quota_project_id = quota_project_id
183182 self ._token_uri = token_uri
184183 self ._always_use_jwt_access = always_use_jwt_access
185- self ._universe_domain = universe_domain or _DEFAULT_UNIVERSE_DOMAIN
184+ self ._universe_domain = universe_domain or credentials . DEFAULT_UNIVERSE_DOMAIN
186185
187- if universe_domain != _DEFAULT_UNIVERSE_DOMAIN :
186+ if universe_domain != credentials . DEFAULT_UNIVERSE_DOMAIN :
188187 self ._always_use_jwt_access = True
189188
190189 self ._jwt_credentials = None
@@ -216,7 +215,9 @@ def _from_signer_and_info(cls, signer, info, **kwargs):
216215 service_account_email = info ["client_email" ],
217216 token_uri = info ["token_uri" ],
218217 project_id = info .get ("project_id" ),
219- universe_domain = info .get ("universe_domain" , _DEFAULT_UNIVERSE_DOMAIN ),
218+ universe_domain = info .get (
219+ "universe_domain" , credentials .DEFAULT_UNIVERSE_DOMAIN
220+ ),
220221 trust_boundary = info .get ("trust_boundary" ),
221222 ** kwargs
222223 )
@@ -316,7 +317,7 @@ def with_always_use_jwt_access(self, always_use_jwt_access):
316317 """
317318 cred = self ._make_copy ()
318319 if (
319- cred ._universe_domain != _DEFAULT_UNIVERSE_DOMAIN
320+ cred ._universe_domain != credentials . DEFAULT_UNIVERSE_DOMAIN
320321 and not always_use_jwt_access
321322 ):
322323 raise exceptions .InvalidValue (
@@ -329,7 +330,7 @@ def with_always_use_jwt_access(self, always_use_jwt_access):
329330 def with_universe_domain (self , universe_domain ):
330331 cred = self ._make_copy ()
331332 cred ._universe_domain = universe_domain
332- if universe_domain != _DEFAULT_UNIVERSE_DOMAIN :
333+ if universe_domain != credentials . DEFAULT_UNIVERSE_DOMAIN :
333334 cred ._always_use_jwt_access = True
334335 return cred
335336
@@ -427,7 +428,10 @@ def refresh(self, request):
427428 # created, try to create one with scopes
428429 self ._create_self_signed_jwt (None )
429430
430- if self ._universe_domain != _DEFAULT_UNIVERSE_DOMAIN and self ._subject :
431+ if (
432+ self ._universe_domain != credentials .DEFAULT_UNIVERSE_DOMAIN
433+ and self ._subject
434+ ):
431435 raise exceptions .RefreshError (
432436 "domain wide delegation is not supported for non-default universe domain"
433437 )
@@ -556,7 +560,7 @@ def __init__(
556560 target_audience ,
557561 additional_claims = None ,
558562 quota_project_id = None ,
559- universe_domain = _DEFAULT_UNIVERSE_DOMAIN ,
563+ universe_domain = credentials . DEFAULT_UNIVERSE_DOMAIN ,
560564 ):
561565 """
562566 Args:
@@ -588,11 +592,11 @@ def __init__(
588592 self ._use_iam_endpoint = False
589593
590594 if not universe_domain :
591- self ._universe_domain = _DEFAULT_UNIVERSE_DOMAIN
595+ self ._universe_domain = credentials . DEFAULT_UNIVERSE_DOMAIN
592596 else :
593597 self ._universe_domain = universe_domain
594598
595- if universe_domain != _DEFAULT_UNIVERSE_DOMAIN :
599+ if universe_domain != credentials . DEFAULT_UNIVERSE_DOMAIN :
596600 self ._use_iam_endpoint = True
597601
598602 if additional_claims is not None :
@@ -708,7 +712,10 @@ def _with_use_iam_endpoint(self, use_iam_endpoint):
708712 default and use_iam_endpoint is False.
709713 """
710714 cred = self ._make_copy ()
711- if cred ._universe_domain != _DEFAULT_UNIVERSE_DOMAIN and not use_iam_endpoint :
715+ if (
716+ cred ._universe_domain != credentials .DEFAULT_UNIVERSE_DOMAIN
717+ and not use_iam_endpoint
718+ ):
712719 raise exceptions .InvalidValue (
713720 "use_iam_endpoint should be True for non-default universe domain"
714721 )
0 commit comments