Skip to content

ConfigDict

ConfigDict

Bases: ConfigDict

Pydantic's ConfigDict extended with the keys JWTModel reads.

Set it as model_config on your token model; the standard Pydantic keys keep working alongside these. Every key is optional.

Examples:

from pydantic_jwt import ConfigDict, JWTModel


class AccessToken(JWTModel):
    model_config = ConfigDict(algorithm='HS256', encoding_key=SECRET, decoding_key=SECRET)

    sub: str

Attributes:

Name Type Description
algorithm str

Algorithm used to sign and verify tokens, e.g. 'HS256'.

encoding_key str | None

Key used to sign tokens in generate().

decoding_key str | None

Key used to verify incoming tokens.

require_keys bool

Whether a missing key is an error. Defaults to True. When False, tokens are accepted without signature verification and a warning is logged.