summaryrefslogtreecommitdiff
path: root/docs/installation.rst
blob: 8d3f3d271fdec448ec71c60a40e29ac904a213d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Installation
============

You can install ``PyJWT`` with ``pip``:

.. code-block:: console

    $ 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.

.. code-block:: console

    $ pip install cryptography

.. _legacy-deps:

Legacy Dependencies
-------------------

Some environments, most notably Google App Engine, do not allow the installation
of Python packages that require compilation of C extensions and therefore
cannot install ``cryptography``. If you can install ``cryptography``, you
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:

.. code-block:: console

    $ pip install pycrypto ecdsa

Once you have installed ``pycrypto`` and ``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.

.. code-block:: python

    import jwt
    from jwt.contrib.algorithms.pycrypto import RSAAlgorithm
    from jwt.contrib.algorithms.py_ecdsa import ECAlgorithm

    jwt.register_algorithm('RS256', RSAAlgorithm(RSAAlgorithm.SHA256))
    jwt.register_algorithm('ES256', ECAlgorithm(ECAlgorithm.SHA256))


.. _`cryptography`: https://cryptography.io