Skip to content
Safely pass trusted data to untrusted environments and back.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs use latest sphinx theme Aug 5, 2019
src/itsdangerous Merge branch '1.1.x' Aug 5, 2019
tests/test_itsdangerous update pre-commit and import order Aug 2, 2019
.azure-pipelines.yaml versions are strings in yaml Aug 5, 2019
.editorconfig add EditorConfig Oct 18, 2018
.gitignore split tests into modules, use pytest, 100% coverage Oct 17, 2018
.pre-commit-config.yaml update pre-commit and import order Aug 2, 2019
CHANGES.rst update docs config Aug 2, 2019
LICENSE.rst standardize license Jul 17, 2019 include tests in sdist Oct 18, 2018
README.rst update tests url Aug 5, 2019
setup.cfg update pre-commit and import order Aug 2, 2019
tox.ini switch ci to azure pipelines Aug 5, 2019



... so better sign this

Various helpers to pass data to untrusted environments and to get it back safe and sound. Data is cryptographically signed to ensure that a token has not been tampered with.

It's possible to customize how data is serialized. Data is compressed as needed. A timestamp can be added and verified automatically while loading a token.


Install and update using pip:

pip install -U itsdangerous

A Simple Example

Here's how you could generate a token for transmitting a user's id and name between web requests.

from itsdangerous import URLSafeSerializer
auth_s = URLSafeSerializer("secret key", "auth")
token = auth_s.dumps({"id": 5, "name": "itsdangerous"})

# eyJpZCI6NSwibmFtZSI6Iml0c2Rhbmdlcm91cyJ9.6YP6T0BaO67XP--9UzTrmurXSmg

data = auth_s.loads(token)
# itsdangerous


The Pallets organization develops and supports ItsDangerous and other popular packages. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today.


You can’t perform that action at this time.