Skip to content

Commit 56957e1

Browse files
committed
Using JWT segment names in verify_signed_jwt_with_certs.
1 parent b0c459f commit 56957e1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

oauth2client/crypt.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,17 @@ def verify_signed_jwt_with_certs(jwt, certs, audience):
137137
AppIdentityError if any checks are failed.
138138
"""
139139
jwt = _to_bytes(jwt)
140-
segments = jwt.split(b'.')
141140

142-
if len(segments) != 3:
143-
raise AppIdentityError('Wrong number of segments in token: %s' % jwt)
144-
message_to_sign = segments[0] + b'.' + segments[1]
141+
if jwt.count(b'.') != 2:
142+
raise AppIdentityError(
143+
'Wrong number of segments in token: %s' % (jwt,))
145144

146-
signature = _urlsafe_b64decode(segments[2])
145+
header, payload, signature = jwt.split(b'.')
146+
message_to_sign = header + b'.' + payload
147+
signature = _urlsafe_b64decode(signature)
147148

148149
# Parse token.
149-
json_body = _urlsafe_b64decode(segments[1])
150+
json_body = _urlsafe_b64decode(payload)
150151
try:
151152
parsed = json.loads(_from_bytes(json_body))
152153
except:

0 commit comments

Comments
 (0)