From 0730cae3ec9453c09845204e9f27b64e0a07a101 Mon Sep 17 00:00:00 2001 From: Abhinav Upadhyay Date: Tue, 4 Dec 2018 14:44:08 +0530 Subject: [PATCH] Decode the auth header string to utf-8 before making request --- pyformance/reporters/opentsdb_reporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyformance/reporters/opentsdb_reporter.py b/pyformance/reporters/opentsdb_reporter.py index 9c887a5..6d39825 100644 --- a/pyformance/reporters/opentsdb_reporter.py +++ b/pyformance/reporters/opentsdb_reporter.py @@ -37,7 +37,7 @@ def report_now(self, registry=None, timestamp=None): data=json.dumps(metrics).encode("utf-8"), headers={'content-type': "application/json"}) authentication_data = "{0}:{1}".format(self.application_name, self.write_key) - auth_header = base64.b64encode(bytes(authentication_data.encode("utf-8"))) + auth_header = base64.b64encode(bytes(authentication_data.encode("utf-8"))).decode("utf-8") request.add_header("Authorization", "Basic {0}".format(auth_header)) urllib.urlopen(request) except Exception as e: