Registry / auth-security / itsdangerous

itsdangerous

JSON →
library2.2.0pypypi✓ verified 24d ago

ItsDangerous is designed to safely pass data to untrusted environments and back. The current version is 2.2.0, with feature releases being frequent and focused on supporting the latest features and removing deprecated code.

pip install itsdangerous
INSTALL
IMPORT
SIG · ITSDANGEROUS
I
itsdangerous
auth-securitypythonv2.2.0
Install
1.6s avg
Import
28ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.028s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.028s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

URLSafeSerializer
from itsdangerous import URLSafeSerializer
Ensure that you import from the correct module for serialization.

Basic usage of ItsDangerous for serializing and deserializing data.

from itsdangerous import URLSafeSerializer serializer = URLSafeSerializer('secret-key') serialized_data = serializer.dumps({'data': 'value'}) deserialized_data = serializer.loads(serialized_data) print(deserialized_data)
Debug
Known issues
breakingSome previously deprecated features were removed in version 2.2.0.
fix
Update your code to use the latest features as per the 2.2.0 documentation.
affects: <=2.1.x
gotchaEnsure your secret key is strong and kept confidential.
fix
Use a sufficiently long and random string for the secret key.
affects: all
gotchaRunning pip as the 'root' user can result in broken permissions and conflicting behavior with the system package manager.
fix
It is recommended to use a virtual environment or run pip as a non-root user.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'itsdangerous'
The 'itsdangerous' library is not installed in your Python environment or is not accessible within the current project's virtual environment.
fix
Install the library using pip: `pip install itsdangerous`
ImportError: cannot import name 'TimedJSONWebSignatureSerializer' from 'itsdangerous'
The `TimedJSONWebSignatureSerializer` class was deprecated and removed in `itsdangerous` version 2.0.0.
fix
Replace `TimedJSONWebSignatureSerializer` with `URLSafeTimedSerializer` (or `TimedSerializer` if URL-safety is not required). Example: `from itsdangerous import URLSafeTimedSerializer as Serializer`
itsdangerous.exc.BadSignature: Signature '...' does not match
This error occurs when the provided signature does not match the computed signature, often due to using a different secret key, a tampered payload, or an incorrect salt between signing and unsigning.
fix
Ensure the same `secret_key` (and `salt`, if used) is consistently used for both signing and unsigning. Also, verify that the signed data has not been modified.
itsdangerous.exc.SignatureExpired: Signature age X > Y seconds
A time-based signature has been received and validated, but its timestamp indicates that it is older than the `max_age` specified during the unsigning process.
fix
Increase the `max_age` parameter when unsigning the token, or generate a new signature if the old one is genuinely stale and needs to be refreshed. Example: `signer.unsign(token, max_age=3600)` (for 1 hour).
Upgrade
Version history
2.2.0latest on PyPI · released Apr 16, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
16
OpenAI (training)
1
Resources
itsdangerous — pip install itsdangerous · libregistry