Skip to content

Commit 5c38bec

Browse files
committed
Black reformatting
1 parent e956fe3 commit 5c38bec

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/sasctl/core.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def __init__(
293293
verify_ssl=None,
294294
token=None,
295295
client_id=None,
296-
client_secret=None
296+
client_secret=None,
297297
):
298298
super(Session, self).__init__()
299299

@@ -417,8 +417,11 @@ def is_ipaddress(hst):
417417

418418
# Find a suitable authentication mechanism and build an auth header
419419
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,
422425
)
423426

424427
# Used for context manager
@@ -702,7 +705,7 @@ def get_auth(
702705
password=None,
703706
token=None,
704707
client_id=None,
705-
client_secret=None
708+
client_secret=None,
706709
):
707710
"""Attempt to authenticate with the Viya environment.
708711
@@ -735,23 +738,22 @@ def get_auth(
735738
Returns
736739
-------
737740
OAuth2Token
738-
Authorization header to use with requests to the evironent
741+
Authorization header to use with requests to the environment
739742
740743
"""
744+
# TODO: Refactor this function to a single set of cases
741745

742746
# If explicit username & password were provided, use them.
743747
if username and password:
748+
return self.get_oauth_token(username, password)
749+
750+
if client_id and client_secret:
744751
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
751753
)
752754

753755
# If an existing access token was provided, use it
754-
if token is not None:
756+
if token:
755757
return OAuth2Token(token)
756758

757759
# Kerberos doesn't require any interruption to the user, so try that first if username/password

0 commit comments

Comments
 (0)