aboutsummaryrefslogtreecommitdiff
path: root/oauth2client/crypt.py
diff options
context:
space:
mode:
authorPat Ferate <pferate+github@gmail.com>2014-07-16 15:59:02 -0700
committerPat Ferate <pferate+github@gmail.com>2014-07-16 15:59:02 -0700
commit60482ed7d8ad3eb4d4e3b38c00c34a4c0f9e9a52 (patch)
treee96d9cd15ef8c29d9679747228222a34a3eca98f /oauth2client/crypt.py
parentd5a10a52b6d010a9dbfdc5847a4f7df2cc0902bc (diff)
downloadoauth2client-60482ed7d8ad3eb4d4e3b38c00c34a4c0f9e9a52.tar.gz
More bytes vs str handling.
Diffstat (limited to 'oauth2client/crypt.py')
-rw-r--r--oauth2client/crypt.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/oauth2client/crypt.py b/oauth2client/crypt.py
index 54980a4..4dd4288 100644
--- a/oauth2client/crypt.py
+++ b/oauth2client/crypt.py
@@ -222,6 +222,10 @@ try:
Returns:
string, The signature of the message for the given key.
"""
+ try:
+ message = str.encode(message)
+ except TypeError:
+ pass
return PKCS1_v1_5.new(self._key).sign(SHA256.new(message))
@staticmethod
@@ -354,12 +358,17 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
raise AppIdentityError(
'Wrong number of segments in token: %s' % jwt)
signed = '%s.%s' % (segments[0], segments[1])
+ try:
+ signed = str.encode(signed)
+ except TypeError:
+ pass
signature = _urlsafe_b64decode(segments[2])
# Parse token.
json_body = _urlsafe_b64decode(segments[1])
try:
+ json_body = bytes.decode(json_body)
parsed = simplejson.loads(json_body)
except:
raise AppIdentityError('Can\'t parse token: %s' % json_body)