@@ -229,37 +229,36 @@ def __init__(self):
229
229
self ._auth_hosts = auth_urls
230
230
self ._auth_host = None
231
231
232
-
233
232
def set_auth_hosts (self , auth_hosts ):
234
233
"""
235
234
Set the available hosts to check for login endpoints.
236
235
237
236
Parameters
238
237
----------
239
238
auth_hosts : array
240
- Available hosts name. Checking each one until one returns a 200 for
239
+ Available hosts name. Checking each one until one returns a 200 for
241
240
the well-known endpoint.
242
241
"""
243
242
self ._auth_hosts = auth_hosts
244
-
243
+
245
244
@property
246
245
def host (self ):
247
246
if self ._auth_host is None :
248
247
for auth_url in self ._auth_hosts :
249
248
# set session cookies (they do not get set otherwise)
250
249
url_to_check = f'https://{ auth_url } { self ._VERIFY_WELL_KNOWN_ENDPOINT } '
251
250
response = self ._request ("HEAD" , url_to_check , cache = False )
252
-
251
+
253
252
if response .status_code == 200 :
254
253
self ._auth_host = auth_url
255
254
log .debug (f'Set auth host to { self ._auth_host } ' )
256
255
break
257
-
256
+
258
257
if self ._auth_host is None :
259
258
raise LoginError (f'No useable hosts to login to: { self ._auth_hosts } ' )
260
259
else :
261
260
return self ._auth_host
262
-
261
+
263
262
def login (self , username , password ):
264
263
"""
265
264
Authenticate to one of the configured hosts.
@@ -288,7 +287,7 @@ def login(self, username, password):
288
287
error_message = json_auth ['error_description' ]
289
288
if self ._INVALID_PASSWORD_MESSAGE not in error_message :
290
289
raise LoginError ("Could not log in to ALMA authorization portal: "
291
- f"{ self .host } Message from server: { error_message } " )
290
+ f"{ self .host } Message from server: { error_message } " )
292
291
else :
293
292
log .error (error_message )
294
293
elif 'access_token' not in json_auth :
@@ -997,11 +996,11 @@ def _login(self, username=None, store_password=False,
997
996
"""
998
997
999
998
self .auth .set_auth_hosts (auth_urls )
1000
-
999
+
1001
1000
username , password = self ._get_auth_info (username = username ,
1002
1001
store_password = store_password ,
1003
1002
reenter_password = reenter_password )
1004
-
1003
+
1005
1004
self .auth .login (username , password )
1006
1005
self .USERNAME = username
1007
1006
0 commit comments