JSON Web Token library for Python 3.
.. image:: https://travis-ci.org/GehirnInc/python-jwt.svg?branch=master :target: https://travis-ci.org/GehirnInc/python-jwt .. image:: https://coveralls.io/repos/GehirnInc/python-jwt/badge.png?branch=master :target: https://coveralls.io/r/GehirnInc/python-jwt?branch=master .. image:: https://badge.fury.io/py/jwt.svg?dummy :target: http://badge.fury.io/py/jwt
python-jwt is a JSON Web Token (JWT) implementation in Python developed by Gehirn Inc
_.
.. code-block:: python
import json
from jwt import ( JWT, jwkfromdict, jwkfrompem, )
message = { 'iss': 'https://example.com/', 'sub': 'yosida95', 'iat': 1485969205, 'exp': 1485972805, }
with open('rsaprivatekey.pem', 'rb') as fh: signingkey = jwkfrom_pem(fh.read())
jwt = JWT() compactjws = jwt.encode(message, signingkey, 'RS256')
with open('rsapublickey.json', 'r') as fh: verifyingkey = jwkfrom_dict(json.load(fh))
messagereceived = jwt.decode(compactjws, verifying_key)
assert message == message_received
You can install python-jwt with pip.
.. code-block:: shell
$ pip install jwt
Supported Algorithms ~~~~~~~~~~~~~~~~~~~~
Unsecured
Symmetric
HS256
HS384
HS512
Asymmetric
RS256
RS384
RS512
Supported Python Versions ~~~~~~~~~~~~~~~~~~~~~~~~~
Python 3.4
Python 3.5
Python 3.6
python-jwt is licensed under the Apache License version 2. See ./LICENSE.rst.
.. _Gehirn Inc: http://www.gehirn.co.jp/