Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 issue #29

Open
charly077 opened this issue Sep 17, 2018 · 1 comment
Open

Python 3 issue #29

charly077 opened this issue Sep 17, 2018 · 1 comment

Comments

@charly077
Copy link

Client.py; get_token(self, code, code_verifier):

return json.loads(token_response.read())
Should be:
return json.loads(token_response.read().decode('utf-8'))

It helps as some response value could be byte encoded.

@pschiffe
Copy link

pschiffe commented Dec 4, 2024

Thank you! I had to edit also base64_urldecode() to make it work:

diff --git a/client.py b/client.py
index ad98c51..db35b1e 100644
--- a/client.py
+++ b/client.py
@@ -273,7 +273,7 @@ class Client:
         except URLError as te:
             print("Could not exchange code for tokens")
             raise te
-        return json.loads(token_response.read())
+        return json.loads(token_response.read().decode('utf-8'))
 
     def get_client_data(self):
         if not self.client_data:
diff --git a/tools.py b/tools.py
index 13acd79..3592c22 100644
--- a/tools.py
+++ b/tools.py
@@ -24,7 +24,7 @@ import ssl
 def base64_urldecode(s):
     ascii_string = str(s)
     ascii_string += '=' * (4 - (len(ascii_string) % 4))
-    return base64.urlsafe_b64decode(ascii_string)
+    return base64.urlsafe_b64decode(ascii_string).decode('utf-8')
 
 
 def base64_urlencode(s):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants