sealedwebtoken
The official Python SDK for Odysii Sealed Web Tokens (SWT).
Installation
# Sync client only (zero dependencies)
pip install sealedwebtoken
# With async support (installs aiohttp)
pip install sealedwebtoken[async]
Usage
Sync
import time
import swt
secret = "your-super-secret-key"
payload = {"user_id": 123, "role": "admin"}
# 1. Sign a token (expiresAt is required, max 31 days)
expires_at = int(time.time()) + 3600 # 1 hour from now
resp = swt.sign(payload, secret=secret, expires_at=expires_at)
print("Token:", resp.token)
print("Expires at:", resp.expires_at)
# 2. Verify a token
v = swt.verify(resp.token, secret=secret)
if v.valid:
print("Payload:", v.payload)
# 3. Revoke a token
swt.revoke(resp.token, secret=secret)
print("Token revoked")
Async
import asyncio, time
import swt
async def main():
client = swt.AsyncSWTClient()
expires_at = int(time.time()) + 3600
resp = await client.sign({"user_id": 42}, secret="mysecret123", expires_at=expires_at)
print("Token:", resp.token)
v = await client.verify(resp.token, secret="mysecret123")
if v.valid:
print("Payload:", v.payload)
await client.revoke(resp.token, secret="mysecret123")
print("Token revoked")
asyncio.run(main())
Using the class-based client
import swt
# Create a reusable client
client = swt.SWTClient()
resp = client.sign({"user_id": 1}, secret="mysecret123", expires_at=...)
API Reference
swt.sign(payload, *, secret, expires_at) → SignResponse
payload—dictto embed in the token (max 512 bytes serialised)secret— string, min 8 charactersexpires_at— Unix timestamp in seconds, required, max 31 days from now
swt.verify(token, *, secret=None) → VerifyResponse
token— the SWT token stringsecret— optional; if provided, validates the secret matches
swt.revoke(token, *, secret) → RevokeResponse
token— the SWT token string to revokesecret— the secret used when signing
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sealedwebtoken-1.0.0.tar.gz
(6.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sealedwebtoken-1.0.0.tar.gz.
File metadata
- Download URL: sealedwebtoken-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f32f231ff02afe3aec6cb03bcd5713c6db4a246a89452e406735b2966e91c86
|
|
| MD5 |
8b9089742a36c55b72d6ddf3a80774bb
|
|
| BLAKE2b-256 |
2c978b4b845be48f16007891e5602fbb67123735fdf43cf1bbc572e252b0068d
|
File details
Details for the file sealedwebtoken-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sealedwebtoken-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eccce3e7e44771615268e825bd2933af9b8036ff3466d83f49d50ed780f6952
|
|
| MD5 |
6bfc7b252b8fa88fd9063c03fd328e45
|
|
| BLAKE2b-256 |
e241d93c98e5b7b351eee04d703e9242680da82477ea77bd55df3627e5f119c6
|