From b4c5b7d81d5757328939944071abcc748111a474 Mon Sep 17 00:00:00 2001 From: gandalv Date: Sat, 12 Jul 2014 22:50:18 +0200 Subject: [PATCH 1/4] Convert the request result content to str. --- oauth2client/client.py | 1 + 1 file changed, 1 insertion(+) diff --git a/oauth2client/client.py b/oauth2client/client.py index 8eb59b1a9..c77d3ae04 100755 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -1648,6 +1648,7 @@ def step2_exchange(self, code, http=None): resp, content = http.request(self.token_uri, method='POST', body=body, headers=headers) + content = str(content, encoding='utf-8') d = _parse_exchange_token_response(content) if resp.status == 200 and 'access_token' in d: access_token = d['access_token'] From 6c867953e6b7b0573afd48821ccf30a90ee1d19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=BDegklitz?= Date: Sun, 13 Jul 2014 00:19:39 +0200 Subject: [PATCH 2/4] Fixed a bytes/str related issue. --- oauth2client/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/oauth2client/client.py b/oauth2client/client.py index c77d3ae04..fa8df3b64 100755 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -1371,8 +1371,10 @@ def verify_id_token(id_token, audience, http=None, def _urlsafe_b64decode(b64string): # Guard against unicode strings, which base64 can't handle. b64string = b64string.encode('ascii') - padded = b64string + '=' * (4 - len(b64string) % 4) - return base64.urlsafe_b64decode(padded) + padded = b64string + b'=' * (4 - len(b64string) % 4) + decoded = base64.urlsafe_b64decode(padded) + decoded = str(decoded, encoding='utf-8') + return decoded def _extract_id_token(id_token): From c06ce515be5dc6ba394de686295db4ed35b29750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=BDegklitz?= Date: Sun, 20 Jul 2014 09:59:10 +0200 Subject: [PATCH 3/4] Bytes/str issue fixed to work in python 2.6. --- oauth2client/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/oauth2client/client.py b/oauth2client/client.py index 5d74053f9..a35ebdb11 100755 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -1,3 +1,4 @@ +from __future__ import print_function # Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -1407,7 +1408,7 @@ def _urlsafe_b64decode(b64string): b64string = b64string.encode('ascii') padded = b64string + b'=' * (4 - len(b64string) % 4) decoded = base64.urlsafe_b64decode(padded) - decoded = str(decoded, encoding='utf-8') + decoded = bytes.decode(decoded) return decoded @@ -1684,7 +1685,7 @@ def step2_exchange(self, code, http=None): resp, content = http.request(self.token_uri, method='POST', body=body, headers=headers) - content = str(content, encoding='utf-8') + content = bytes.decode(content) d = _parse_exchange_token_response(content) if resp.status == 200 and 'access_token' in d: access_token = d['access_token'] From a8381ffcc96dd5267fbbd71797ed5b507789e8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=BDegklitz?= Date: Sun, 20 Jul 2014 10:16:59 +0200 Subject: [PATCH 4/4] Removed forgotten __future__ import. --- oauth2client/client.py | 1 - 1 file changed, 1 deletion(-) diff --git a/oauth2client/client.py b/oauth2client/client.py index a35ebdb11..f68036097 100755 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -1,4 +1,3 @@ -from __future__ import print_function # Copyright (C) 2010 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License");