diff options
-rw-r--r-- | README.rst | 3 | ||||
-rw-r--r-- | docs/index.rst | 5 | ||||
-rw-r--r-- | jwt/api_jws.py | 4 |
3 files changed, 8 insertions, 4 deletions
@@ -41,7 +41,8 @@ Usage >>> import jwt >>> encoded = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256') - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg' + >>> print(encoded) + eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg >>> jwt.decode(encoded, 'secret', algorithms=['HS256']) {'some': 'payload'} diff --git a/docs/index.rst b/docs/index.rst index e717bdd..2ad1e09 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,12 +30,13 @@ Example Usage ------------- .. code-block:: python +.. doctest:: >>> import jwt >>> encoded_jwt = jwt.encode({'some': 'payload'}, 'secret', algorithm='HS256') - >>> encoded_jwt - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg' + >>> print(encoded_jwt) + eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg >>> jwt.decode(encoded_jwt, 'secret', algorithms=['HS256']) {'some': 'payload'} diff --git a/jwt/api_jws.py b/jwt/api_jws.py index 287dbf4..84465c1 100644 --- a/jwt/api_jws.py +++ b/jwt/api_jws.py @@ -126,7 +126,9 @@ class PyJWS: segments.append(base64url_encode(signature)) - return b".".join(segments) + encoded_string = b".".join(segments) + + return encoded_string.decode("utf-8") def decode( self, |