Exceptions

exception itsdangerous.exc.BadData(message)

Raised if bad data of any sort was encountered. This is the base for all exceptions that ItsDangerous defines.

Changelog

New in version 0.15.

Parameters

message (str) –

exception itsdangerous.exc.BadSignature(message, payload=None)

Raised if a signature does not match.

Parameters
payload: Optional[Any]

The payload that failed the signature test. In some situations you might still want to inspect this, even if you know it was tampered with.

Changelog

New in version 0.14.

exception itsdangerous.exc.BadTimeSignature(message, payload=None, date_signed=None)

Raised if a time-based signature is invalid. This is a subclass of BadSignature.

Parameters
date_signed

If the signature expired this exposes the date of when the signature was created. This can be helpful in order to tell the user how long a link has been gone stale.

Changed in version 2.0: The datetime value is timezone-aware rather than naive.

Changelog

New in version 0.14.

exception itsdangerous.exc.SignatureExpired(message, payload=None, date_signed=None)

Raised if a signature timestamp is older than max_age. This is a subclass of BadTimeSignature.

Parameters
exception itsdangerous.exc.BadHeader(message, payload=None, header=None, original_error=None)

Raised if a signed header is invalid in some form. This only happens for serializers that have a header that goes with the signature.

Changelog

New in version 0.24.

Parameters
header: Optional[Any]

If the header is actually available but just malformed it might be stored here.

original_error: Optional[Exception]

If available, the error that indicates why the payload was not valid. This might be None.

exception itsdangerous.exc.BadPayload(message, original_error=None)

Raised if a payload is invalid. This could happen if the payload is loaded despite an invalid signature, or if there is a mismatch between the serializer and deserializer. The original exception that occurred during loading is stored on as original_error.

Changelog

New in version 0.15.

Parameters
original_error: Optional[Exception]

If available, the error that indicates why the payload was not valid. This might be None.