diff --git a/oauth2client/client.py b/oauth2client/client.py index b851fe9c0..f68036097 100755 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -1405,8 +1405,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 = bytes.decode(decoded) + return decoded def _extract_id_token(id_token): @@ -1682,6 +1684,7 @@ def step2_exchange(self, code, http=None): resp, content = http.request(self.token_uri, method='POST', body=body, headers=headers) + content = bytes.decode(content) d = _parse_exchange_token_response(content) if resp.status == 200 and 'access_token' in d: access_token = d['access_token']