]> git.ipfire.org Git - oddments/ddns.git/commitdiff
Port base64 authorization to python3
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 30 Jan 2020 18:59:38 +0000 (19:59 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 30 Jan 2020 18:59:38 +0000 (19:59 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/ddns/system.py

index c2dc4309e6c39adb0ac53db2b87dd3f4de7b4992..73a27a5cd0b56484feda70006b3ba4065e11e0c8 100644 (file)
@@ -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