Skip to content

Commit

Permalink
Add headers to debugging, obfuscate authorisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrance committed Mar 10, 2023
1 parent a24999d commit 8f4d493
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion skpy/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 8f4d493

Please sign in to comment.