From cc38f69e81aa9110ad5711b2376a12b07634aad8 Mon Sep 17 00:00:00 2001 From: silkerp <16793725+silkerp@users.noreply.github.com> Date: Thu, 30 Aug 2018 08:31:28 +0300 Subject: [PATCH] Encoding issue I was getting an encoding error: ---> 27 dev_hash.update(timestamp) TypeError: Unicode-objects must be encoded before hashing So I added encode(utf-8) to both timestamp and api_secret which resolved the issue. --- onesky/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onesky/client.py b/onesky/client.py index ef64ba7..9c62c60 100644 --- a/onesky/client.py +++ b/onesky/client.py @@ -15,12 +15,12 @@ def __init__(self, api_key, api_secret, request_callback=None): self.api_url = api_url self.api_key = api_key - self.api_secret = api_secret + self.api_secret = api_secret.encode('utf-8') self.download_dir = download_dir self.request_callback = request_callback def create_auth_variables(self): - timestamp = str(int(time.time())) + timestamp = str(int(time.time())).encode('utf-8') dev_hash = hashlib.md5() dev_hash.update(timestamp)