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) → VerifyResponse

  • token — the SWT token string
  • secret — string, min 8 characters, required

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.2

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.2
File Size Uploaded
sealedwebtoken-1.0.2.tar.gz 6.2 kB Details

Built distribution (wheel)

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

Total release size: 10.6 kB

Release files / sealedwebtoken-1.0.2.tar.gz

Download URL sealedwebtoken-1.0.2.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
44be16b7dfcfbdea18d2446b5dbbc0edb9152c4776d3b10a24c0f880ba080284
BLAKE2b-256 checksum
How to use checksums
68fcbfa858f6b6426b2ceb07229c97ea9d7b05fc2156697f79e68a309b7d15c3
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.2-py3-none-any.whl

Download URL sealedwebtoken-1.0.2-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc53c804427144e7637c688c855f100ec63f88934bd93049f940e91afefdb31e
BLAKE2b-256 checksum
How to use checksums
c4d5373be0334e4d5800688e502cec77794bb4f01342b8dc9824cdab4c6a6d46
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

This release

1.0.2 This release

2 release files

1.0.1

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