From 8f4d493ea5e89263e7b4f2bee33f0885c6cac994 Mon Sep 17 00:00:00 2001 From: Ollie Terrance Date: Fri, 10 Mar 2023 19:14:55 +0000 Subject: [PATCH] Add headers to debugging, obfuscate authorisation --- skpy/conn.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/skpy/conn.py b/skpy/conn.py index 05e7f4a..8fa115d 100644 --- a/skpy/conn.py +++ b/skpy/conn.py @@ -215,15 +215,19 @@ def __call__(self, method, url, codes=(200, 201, 202, 204, 207), auth=None, head self.verifyToken(auth) if not headers: headers = {} + debugHeaders = dict(headers) if auth == self.Auth.SkypeToken: headers["X-SkypeToken"] = self.tokens["skype"] + debugHeaders["X-SkypeToken"] = "***" elif auth == self.Auth.Authorize: headers["Authorization"] = "skype_token {0}".format(self.tokens["skype"]) + debugHeaders["Authorization"] = "***" elif auth == self.Auth.RegToken: headers["RegistrationToken"] = self.tokens["reg"] + debugHeaders["RegistrationToken"] = "***" if os.getenv("SKPY_DEBUG_HTTP"): print("<= [{0}] {1} {2}".format(datetime.now().strftime("%d/%m %H:%M:%S"), method, url)) - print(pformat(kwargs)) + print(pformat(dict(kwargs, headers=debugHeaders))) resp = self.sess.request(method, url, headers=headers, **kwargs) if os.getenv("SKPY_DEBUG_HTTP"): print("=> [{0}] {1}".format(datetime.now().strftime("%d/%m %H:%M:%S"), resp.status_code))