Skip to content

Commit 8fd8fe8

Browse files
author
Kiran Kumaraswamy
committed
fix username passwrd authentication issue
1 parent 537f600 commit 8fd8fe8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

dsms/core/configuration.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""General config for the DSMS Python SDK"""
22

3+
import base64
34
import logging
45
import urllib
56
import warnings
@@ -296,7 +297,11 @@ def validate_auth(self):
296297
)
297298
elif username and passwd:
298299
url = urllib.parse.urljoin(str(host_url), "api/users/token")
299-
authorization = f"Basic {username.get_secret_value()}:{passwd.get_secret_value()}" # pylint: disable=no-member
300+
# FastAPI HTTPBasic requires base64-encoded credentials; old Flask endpoint accepted raw
301+
_credentials = base64.b64encode(
302+
f"{username.get_secret_value()}:{passwd.get_secret_value()}".encode() # pylint: disable=no-member
303+
).decode()
304+
authorization = f"Basic {_credentials}"
300305
logger.debug("Sending get request to %s", url)
301306
response = requests.get(
302307
url,

0 commit comments

Comments
 (0)