Skip to content

Config

First we need to prepare the config. A config is a dictionary of the form:

{
    "alg": "RS256",
    "secret_key": "kdhfkjdwffuw",
    "public_key": None,
    "private_key": None,
    "expire": 3600,
    "list": None
}

alg

Currently available algorithms are HS256, HS384, HS512, RS256, RS384, RS512.

For HS* algorithms it is necessary to specify secret_key. It can be generated by the secrets library built into python.

For RS* algorithms it is necessary to specify public_key and private_key, you can use jam.utils.generate_rsa_key_pair.

expire

This is the lifetime of the token in seconds.

list

This is a module for working with black/white lists. See Jam List documentaion.

You can use jam.utils.make_jwt_config.

from jam.utils import make_jwt_config

config = make_jwt_config(
    alg="HS256",
    secret_key="your_super_secret_key",
    expire=3600,
)