@@ -293,7 +293,7 @@ def __init__(
293
293
verify_ssl = None ,
294
294
token = None ,
295
295
client_id = None ,
296
- client_secret = None
296
+ client_secret = None ,
297
297
):
298
298
super (Session , self ).__init__ ()
299
299
@@ -417,8 +417,11 @@ def is_ipaddress(hst):
417
417
418
418
# Find a suitable authentication mechanism and build an auth header
419
419
self .auth = self .get_auth (
420
- self ._settings ["username" ], self ._settings ["password" ], token ,
421
- client_id = client_id , client_secret = client_secret
420
+ self ._settings ["username" ],
421
+ self ._settings ["password" ],
422
+ token ,
423
+ client_id = client_id ,
424
+ client_secret = client_secret ,
422
425
)
423
426
424
427
# Used for context manager
@@ -702,7 +705,7 @@ def get_auth(
702
705
password = None ,
703
706
token = None ,
704
707
client_id = None ,
705
- client_secret = None
708
+ client_secret = None ,
706
709
):
707
710
"""Attempt to authenticate with the Viya environment.
708
711
@@ -735,23 +738,22 @@ def get_auth(
735
738
Returns
736
739
-------
737
740
OAuth2Token
738
- Authorization header to use with requests to the evironent
741
+ Authorization header to use with requests to the environment
739
742
740
743
"""
744
+ # TODO: Refactor this function to a single set of cases
741
745
742
746
# If explicit username & password were provided, use them.
743
747
if username and password :
748
+ return self .get_oauth_token (username , password )
749
+
750
+ if client_id and client_secret :
744
751
return self .get_oauth_token (
745
- username , password
746
- )
747
- if client_id is not None and client_secret is not None :
748
- return self .get_oauth_token (
749
- client_id = client_id ,
750
- client_secret = client_secret
752
+ client_id = client_id , client_secret = client_secret
751
753
)
752
754
753
755
# If an existing access token was provided, use it
754
- if token is not None :
756
+ if token :
755
757
return OAuth2Token (token )
756
758
757
759
# Kerberos doesn't require any interruption to the user, so try that first if username/password
0 commit comments