From be3d4fce5a5c9663ae15f252b17588c31a5aa116 Mon Sep 17 00:00:00 2001 From: dtk Date: Wed, 27 Apr 2016 14:55:50 +0200 Subject: [PATCH] Make `get_unverified_claims()` return a dict So far the above method returned the unprocessed string it received from `_load()`. This commit parses the payload before returning it in order to comply with the documentation. --- jose/jws.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jose/jws.py b/jose/jws.py index 3d530f4b..1e104633 100644 --- a/jose/jws.py +++ b/jose/jws.py @@ -124,7 +124,11 @@ def get_unverified_claims(token): JWSError: If there is an exception decoding the token. """ header, claims, signing_input, signature = _load(token) - return claims + + try: + return json.loads(claims.decode('utf-8')) + except ValueError as e: + raise JWSError('Invalid claims string: %s' % e) def _encode_header(algorithm, additional_headers=None):