From 921d1afbeaf1b71309d121a7da4ed35e59c0c241 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Thu, 30 Jan 2020 19:59:38 +0100 Subject: [PATCH] Port base64 authorization to python3 Signed-off-by: Stefan Schantl --- src/ddns/system.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/ddns/system.py b/src/ddns/system.py index c2dc430..73a27a5 100644 --- a/src/ddns/system.py +++ b/src/ddns/system.py @@ -142,7 +142,7 @@ class DDNSSystem(object): if username and password: basic_auth_header = self._make_basic_auth_header(username, password) - req.add_header("Authorization", "Basic %s" % basic_auth_header) + req.add_header("Authorization", "Basic %s" % basic_auth_header.decode()) # Set the user agent. req.add_header("User-Agent", self.USER_AGENT) @@ -259,10 +259,7 @@ class DDNSSystem(object): authstring = "%s:%s" % (username, password) # Encode authorization data in base64. - authstring = base64.encodebytes(authstring) - - # Remove any newline characters. - authstring = authstring.replace("\n", "") + authstring = base64.b64encode(authstring.encode()) return authstring -- 2.39.2