Home
Welcome to Jam documentation!
About¶
Jam(Jeneric auth module) - a simple library that makes implementing authentication in your application effortless.
Installation¶
pip install jamlibInstalled!
Quick example¶
from jam import Jam
jam = Jam(config="config.toml")
payload = {
"user": 1
}
jwt = jam.jwt_create(payload)
session_id = jam.session_create("user@mail.com", payload)
otp_code = jam.otp_code(secret="7K2HVNA3IQCYFFDX76IXKNCZHQ")
Asynchronous support¶
Note
You can use jam.aio module to work with async functions. The methods are the same, but you need to use await keyword.
from jam.aio import Jam
jam = Jam()
payload = await jam.jwt_make_payload(
exp=3600, data={"user_id": 1}
)
token = await jam.jwt_create(payload)
Why Jam?¶
Jam is a library that provides the most popular AUTH* mechanisms right out of the box.
Framework integrations¶
Jam provides ready-to-use integrations for the most popular frameworks:
Each integration offers built-in middleware or plugin support for JWT and session-based authentication.
Why choose Jam?¶
Jam supports many authentication methods out of the box with minimal dependencies. Here is a comparison with other libraries:
| Features / Library | Jam | Authx | PyJWT | AuthLib | OTP Auth |
|---|---|---|---|---|---|
| JWT | ✅ | ✅ | ✅ | ✅ | ❌ |
| JWT black/white lists | ✅ | ❌ | ❌ | ❌ | ❌ |
| PASETO | ✅ | ❌ | ❌ | ❌ | ❌ |
| Server side sessions | ✅ | ✅ | ❌ | ❌ | ❌ |
| OTP | ✅ | ❌ | ❌ | ❌ | ✅ |
| OAuth2 | ✅ | ✅ | ❌ | ✅ | ❌ |
| Flexible config | ✅ | ❌ | ❌ | ❌ | ❌ |
| Modularity | ✅ | ❌ | ❌ | ❌ | ❌ |