Skip to main content

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 — dict to embed in the token (max 512 bytes serialised)
  • secret — string, min 8 characters
  • expires_at — Unix timestamp in seconds, required, max 31 days from now

swt.verify(token, *, secret=None) → VerifyResponse

  • token — the SWT token string
  • secret — optional; if provided, validates the secret matches

swt.revoke(token, *, secret) → RevokeResponse

  • token — the SWT token string to revoke
  • secret — the secret used when signing

Metadata

Release files for sealedwebtoken 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sealedwebtoken 1.0.1
File Size Uploaded
sealedwebtoken-1.0.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sealedwebtoken 1.0.1
File Interpreter ABI Platform
sealedwebtoken-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / sealedwebtoken-1.0.1.tar.gz

Download URL sealedwebtoken-1.0.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f97111e953ec0dec824d884e4fa990416ff7ffc47a869fca94ce01008564734d
BLAKE2b-256 checksum
How to use checksums
d7859fade60c11d739e031608f03cfe014521ba88e6ab42bb395d524caf4a7bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / sealedwebtoken-1.0.1-py3-none-any.whl

Download URL sealedwebtoken-1.0.1-py3-none-any.whl
Size 4.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6c1514acb961e4826a396af80d30a3431e8784fa09b41ec3075936d60d985550
BLAKE2b-256 checksum
How to use checksums
227a2314f986d91b138a2ec4ee61b9395989ca04e7c0a6d47f32e53f36f9fd36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

1.0.2

2 release files

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page