diff options
author | José Padilla <jpadilla@webapplicate.com> | 2020-08-22 11:55:43 -0400 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2020-08-22 11:57:18 -0400 |
commit | 3a44c74ebf39f15c0633247e5d70c414840a4523 (patch) | |
tree | f44a64f97556ad69ccc5e23d2428f5c11404172a | |
parent | d926a4db6ecea382556c026779541b377e36d311 (diff) | |
download | pyjwt-string-tokens.tar.gz |
Return tokens as string not bytesstring-tokens
-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, |