Skip to content

Commit

Permalink
Update authorization header encoding for Bearer and Basic auth to str…
Browse files Browse the repository at this point in the history
…ings instead of byte strings.
  • Loading branch information
julienblin-kothar committed Feb 6, 2025
1 parent 5f4c48c commit ae83cb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions h5pyd/_hl/httpconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,14 @@ def getHeaders(self, username=None, password=None, headers=None):

if token:
auth_string = b"Bearer " + token.encode("ascii")
headers["Authorization"] = auth_string
headers["Authorization"] = auth_string.decode("ascii")
elif username is not None and password is not None:
self.log.debug(f"use basic auth with username: {username}")
auth_string = username + ":" + password
auth_string = auth_string.encode("utf-8")
auth_string = base64.b64encode(auth_string)
auth_string = b"Basic " + auth_string
headers["Authorization"] = auth_string
headers["Authorization"] = auth_string.decode("utf-8")
else:
self.log.debug("no auth header")
# no auth header
Expand Down

0 comments on commit ae83cb9

Please sign in to comment.