| 1 |
PyJWT |
| 2 |
===== |
| 3 |
|
| 4 |
.. image:: https://github.com/jpadilla/pyjwt/workflows/CI/badge.svg |
| 5 |
:target: https://github.com/jpadilla/pyjwt/actions?query=workflow%3ACI |
| 6 |
|
| 7 |
.. image:: https://img.shields.io/pypi/v/pyjwt.svg |
| 8 |
:target: https://pypi.python.org/pypi/pyjwt |
| 9 |
|
| 10 |
.. image:: https://codecov.io/gh/jpadilla/pyjwt/branch/master/graph/badge.svg |
| 11 |
:target: https://codecov.io/gh/jpadilla/pyjwt |
| 12 |
|
| 13 |
.. image:: https://readthedocs.org/projects/pyjwt/badge/?version=stable |
| 14 |
:target: https://pyjwt.readthedocs.io/en/stable/ |
| 15 |
|
| 16 |
A Python implementation of `RFC 7519 <https://tools.ietf.org/html/rfc7519>`_. Original implementation was written by `@progrium <https://github.com/progrium>`_. |
| 17 |
|
| 18 |
Sponsor |
| 19 |
------- |
| 20 |
|
| 21 |
.. |auth0-logo| image:: https://github.com/user-attachments/assets/ee98379e-ee76-4bcb-943a-e25c4ea6d174 |
| 22 |
:width: 160px |
| 23 |
|
| 24 |
+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 25 |
| |auth0-logo| | If you want to quickly add secure token-based authentication to Python projects, feel free to check Auth0's Python SDK and free plan at `auth0.com/signup <https://auth0.com/signup?utm_source=external_sites&utm_medium=pyjwt&utm_campaign=devn_signup>`_. | |
| 26 |
+--------------+-----------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ |
| 27 |
|
| 28 |
Installing |
| 29 |
---------- |
| 30 |
|
| 31 |
Install with **pip**: |
| 32 |
|
| 33 |
.. code-block:: console |
| 34 |
|
| 35 |
$ pip install PyJWT |
| 36 |
|
| 37 |
|
| 38 |
Usage |
| 39 |
----- |
| 40 |
|
| 41 |
.. code-block:: pycon |
| 42 |
|
| 43 |
>>> import jwt |
| 44 |
>>> encoded = jwt.encode({"some": "payload"}, "secret", algorithm="HS256") |
| 45 |
>>> print(encoded) |
| 46 |
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzb21lIjoicGF5bG9hZCJ9.4twFt5NiznN84AWoo1d7KO1T_yoc0Z6XOpOVswacPZg |
| 47 |
>>> jwt.decode(encoded, "secret", algorithms=["HS256"]) |
| 48 |
{'some': 'payload'} |
| 49 |
|
| 50 |
Documentation |
| 51 |
------------- |
| 52 |
|
| 53 |
View the full docs online at https://pyjwt.readthedocs.io/en/stable/ |
| 54 |
|
| 55 |
|
| 56 |
Tests |
| 57 |
----- |
| 58 |
|
| 59 |
You can run tests from the project root after cloning with: |
| 60 |
|
| 61 |
.. code-block:: console |
| 62 |
|
| 63 |
$ tox |