You can install
$ pip install pyjwt
Cryptographic Dependencies (Optional)¶
If you are planning on encoding or decoding tokens using certain digital signature algorithms (like RSA or ECDSA), you will need to install the cryptography library.
$ pip install cryptography
Some environments, most notably Google App Engine, do not allow the installation
of Python packages that require compilation of C extensions and therefore
cryptography. If you can install
should disregard this section.
If you are deploying an application to one of these environments, you may need to use the legacy implementations of the digital signature algorithms:
$ pip install pycrypto ecdsa
Once you have installed
ecdcsa, you can tell PyJWT to use
the legacy implementations with
jwt.register_algorithm(). The following
example code shows how to configure PyJWT to use the legacy implementations
for RSA with SHA256 and EC with SHA256 signatures.
import jwt from jwt.contrib.algorithms.pycrypto import RSAAlgorithm from jwt.contrib.algorithms.py_ecdsa import ECAlgorithm jwt.unregister_algorithm('RS256') jwt.unregister_algorithm('ES256') jwt.register_algorithm('RS256', RSAAlgorithm(RSAAlgorithm.SHA256)) jwt.register_algorithm('ES256', ECAlgorithm(ECAlgorithm.SHA256))