@@ -77,6 +77,7 @@ def _warn_about_problematic_credentials(credentials):
7777 warnings .warn (_CLOUD_SDK_CREDENTIALS_WARNING )
7878
7979
80+ # deprecate
8081def load_credentials_from_file (
8182 filename , scopes = None , default_scopes = None , quota_project_id = None , request = None
8283):
@@ -125,16 +126,37 @@ def load_credentials_from_file(
125126 )
126127 raise new_exc from caught_exc
127128 return _load_credentials_from_info (
128- filename , info , scopes , default_scopes , quota_project_id , request
129+ filename ,
130+ info ,
131+ scopes ,
132+ default_scopes ,
133+ quota_project_id ,
134+ request ,
135+ constraints .Constraints .allow_everything_insecure (),
129136 )
130137
138+
139+ # deprecate
131140def load_credentials_from_dict (
132141 info , scopes = None , default_scopes = None , quota_project_id = None , request = None
133142):
134- return load_credentials_from_dict_with_constraints (info , constraints .Constraints (allow_types = "all" ), scopes , default_scopes , quota_project_id , request )
143+ return load_credentials_from_dict_constrained (
144+ info ,
145+ constraints .Constraints .allow_everything_insecure (),
146+ scopes ,
147+ default_scopes ,
148+ quota_project_id ,
149+ request ,
150+ )
135151
136- def load_credentials_from_dict_with_constraints (
137- info , constraints , scopes = None , default_scopes = None , quota_project_id = None , request = None
152+
153+ def load_credentials_from_dict_constrained (
154+ info ,
155+ constraints ,
156+ scopes = None ,
157+ default_scopes = None ,
158+ quota_project_id = None ,
159+ request = None ,
138160):
139161 """Loads Google credentials from a dict.
140162
@@ -173,7 +195,13 @@ def load_credentials_from_dict_with_constraints(
173195 )
174196
175197 return _load_credentials_from_info (
176- "dict object" , info , scopes , default_scopes , quota_project_id , request
198+ "dict object" ,
199+ info ,
200+ scopes ,
201+ default_scopes ,
202+ quota_project_id ,
203+ request ,
204+ constraints ,
177205 )
178206
179207
@@ -184,8 +212,10 @@ def _load_credentials_from_info(
184212
185213 credential_type = info .get ("type" )
186214
187- if constraints .isValid (info ) is False :
188- raise exceptions .InvalidType (f"{ credential_type } is not allowed as per provided constraints or is not a valid credential type" )
215+ if constraints .is_valid (info ) is False :
216+ raise exceptions .InvalidType (
217+ f"The provided { credential_type } is not allowed as per provided constraints or is not a valid credential type"
218+ )
189219
190220 if credential_type == _AUTHORIZED_USER_TYPE :
191221 credentials , project_id = _get_authorized_user_credentials (
0 commit comments