From 288c3432831916d5e6717db06c1cf61c2bf994ba Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Wed, 21 Apr 2021 18:53:17 -0500 Subject: [PATCH 1/2] cast body to str first --- cbpro/cbpro_auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cbpro/cbpro_auth.py b/cbpro/cbpro_auth.py index db6561fe..74f498e4 100644 --- a/cbpro/cbpro_auth.py +++ b/cbpro/cbpro_auth.py @@ -14,8 +14,9 @@ def __init__(self, api_key, secret_key, passphrase): def __call__(self, request): timestamp = str(time.time()) + body = str(request.body) if request.body else '' message = ''.join([timestamp, request.method, - request.path_url, (request.body or '')]) + request.path_url, body]) request.headers.update(get_auth_headers(timestamp, message, self.api_key, self.secret_key, From 5339fdee8cdb7ed35a4c41b0f533b333db9e054b Mon Sep 17 00:00:00 2001 From: unparalleled-js Date: Wed, 21 Apr 2021 19:46:42 -0500 Subject: [PATCH 2/2] fix auth bug correctly --- cbpro/cbpro_auth.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cbpro/cbpro_auth.py b/cbpro/cbpro_auth.py index 74f498e4..fe0f6fda 100644 --- a/cbpro/cbpro_auth.py +++ b/cbpro/cbpro_auth.py @@ -14,9 +14,12 @@ def __init__(self, api_key, secret_key, passphrase): def __call__(self, request): timestamp = str(time.time()) - body = str(request.body) if request.body else '' - message = ''.join([timestamp, request.method, - request.path_url, body]) + message = ( + timestamp + + request.method + + request.path_url + + (request.body or b"").decode() + ) request.headers.update(get_auth_headers(timestamp, message, self.api_key, self.secret_key,