diff --git a/stetl/inputs/httpinput.py b/stetl/inputs/httpinput.py index 90998af..b15be9e 100644 --- a/stetl/inputs/httpinput.py +++ b/stetl/inputs/httpinput.py @@ -113,7 +113,8 @@ def add_authorization(self, request): # Basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html # base64 encode username and password # write the Authorization header like: 'Basic base64encode(username + ':' + password) - auth_val = base64.encodestring('%s:%s' % (auth_creds['user'], auth_creds['password'])) + creds = '%s:%s' % (auth_creds['user'], auth_creds['password']) + auth_val = base64.b64encode(creds.encode('utf-8')).decode('utf-8') auth_val = "Basic %s" % auth_val elif auth_type == 'token': # Bearer Type, see eg. https://tools.ietf.org/html/rfc6750 diff --git a/stetl/outputs/httpoutput.py b/stetl/outputs/httpoutput.py index 03fafc4..ab8370f 100644 --- a/stetl/outputs/httpoutput.py +++ b/stetl/outputs/httpoutput.py @@ -107,8 +107,9 @@ def post(self, packet, payload): # basic auth: http://mozgovipc.blogspot.nl/2012/06/python-http-basic-authentication-with.html # base64 encode the username and password # write the Authorization header like: 'Basic base64encode(username + ':' + password) - if self.user is not None: - auth = base64.encodestring('%s:%s' % (self.user, self.password)).replace('\n', '') + if self.user is not None and self.password is not None: + creds = '%s:%s' % (self.user, self.password) + auth = base64.b64encode(creds.encode('utf-8')).decode('utf-8') webservice.putheader("Authorization", "Basic %s" % auth) webservice.endheaders()