Add HTTP basic auth builder

This commit is contained in:
Clemens Schwaighofer
2025-07-26 11:26:09 +09:00
parent 3cd3f87d68
commit d1ea9874da

View File

@@ -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}'