JOSE implementation in Python providing JWT, JWS, JWE, and JWK functionality with multiple cryptographic backends.
75
Create a tiny helper for issuing and validating compact JWT strings backed by a shared secret.
sub, iss, aud, iat, and exp claims using the provided inputs, with iat set to the current UTC time and exp set to iat + expires_in_seconds. @testnot_before_seconds is omitted the token is immediately valid; when provided it sets nbf to iat + not_before_seconds. @testissue_token verifies successfully with the correct secret, issuer, and audience, returning a mapping of claims with numeric timestamps. @testaud does not match the expected audience. @test@generates
def issue_token(
subject: str,
secret: str,
issuer: str,
audience: str,
expires_in_seconds: int,
not_before_seconds: int | None = None,
) -> str:
"""Return a signed JWT string containing subject and standard claims."""
def validate_token(
token: str,
secret: str,
issuer: str,
audience: str,
leeway_seconds: int = 0,
) -> dict:
"""Verify signature plus issuer, audience, and temporal claims; return claims on success and raise on failure."""Provides JWT encoding, decoding, and claim validation support.
Install with Tessl CLI
npx tessl i tessl/pypi-python-jose