Skip to content

Commit b8ea83d

Browse files
committed
fix: aspen, revert to token based auth if krb fails
1 parent 99266c9 commit b8ea83d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

tagreader/clients.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PIHandlerWeb,
2222
get_auth_aspen,
2323
get_auth_pi,
24+
get_url_aspen,
2425
list_aspenone_sources,
2526
list_piwebapi_sources,
2627
)
@@ -121,17 +122,34 @@ def get_handler(
121122
url: Optional[str],
122123
options: Dict[str, Union[int, float, str]],
123124
verify_ssl: Optional[Union[bool, str]],
124-
auth: Optional[Any],
125+
auth: Optional[Any] = None,
125126
cache: Optional[Union[SmartCache, BucketCache]] = None,
126127
):
127128
if imstype is None:
129+
orig_auth = auth
130+
orig_url = url
128131
try:
129-
if datasource in list_aspenone_sources(
132+
aspen_source = list_aspenone_sources(
130133
url=None, auth=None, verify_ssl=verify_ssl
131-
):
132-
imstype = IMSType.ASPENONE
133-
except requests.exceptions.HTTPError as e:
134-
logger.debug(f"Could not list Aspenone sources: {e}")
134+
)
135+
except requests.exceptions.HTTPError:
136+
# Try again using app registration auth
137+
try:
138+
auth = get_auth_aspen(False)
139+
url = get_url_aspen(False)
140+
aspen_source = list_aspenone_sources(
141+
auth=auth, url=url, verify_ssl=verify_ssl
142+
)
143+
except requests.exceptions.HTTPError as e:
144+
logger.debug(f"Could not list Aspenone sources: {e}")
145+
aspen_source = []
146+
147+
if datasource in aspen_source:
148+
imstype = IMSType.ASPENONE
149+
else:
150+
auth = orig_auth
151+
url = orig_url
152+
135153
if imstype is None:
136154
try:
137155
if datasource in list_piwebapi_sources(

0 commit comments

Comments
 (0)