From d1ea9874dabbdc03712107a7b74c0c114987644a Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Sat, 26 Jul 2025 11:26:09 +0900 Subject: [PATCH] Add HTTP basic auth builder --- .../requests_handling/auth_helpers.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/corelibs/requests_handling/auth_helpers.py diff --git a/src/corelibs/requests_handling/auth_helpers.py b/src/corelibs/requests_handling/auth_helpers.py new file mode 100644 index 0000000..e46b8ea --- /dev/null +++ b/src/corelibs/requests_handling/auth_helpers.py @@ -0,0 +1,20 @@ +""" +Various HTTP auth helpers +""" + +from base64 import b64encode + + +def basic_auth(username: str, password: str) -> str: + """ + setup basic auth, for debug + + Arguments: + username {str} -- _description_ + password {str} -- _description_ + + Returns: + str -- _description_ + """ + token = b64encode(f"{username}:{password}".encode('utf-8')).decode("ascii") + return f'Basic {token}'