Skip to main content

A lightweight utility to create, validate, and refresh JWT tokens easily.

Project description

JWTManager - A Lightweight JWT Utility Package

JWTManager is a lightweight and simple Python utility package for handling JSON Web Tokens (JWT). It allows you to easily create, validate, and refresh JWT tokens, with built-in customizable expiration, multiple algorithms, and custom exception handling.

Features

  • Create JWT access tokens with customizable expiration
  • Validate JWT tokens securely
  • Refresh expired or about-to-expire tokens
  • Supports HS256, HS384, HS512 algorithms
  • Built-in logging for important events
  • Custom exception handling for token errors

Installation

pip install jwt_manager

Usage

from jwt_manager import JWTManager, InvalidTokenError

# Secret key
secret = "my_secret_key"

# Create a token
token = JWTManager.create_token({"user_id": 123}, secret, expiry_minutes=30)

# Validate the token
try:
    payload = JWTManager.validate_token(token, secret)
except InvalidTokenError:
    print("Token is invalid!")

# Refresh the token
new_token = JWTManager.refresh_token(token, secret, additional_minutes=60)

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jwt_manager-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jwt_manager-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file jwt_manager-0.1.0.tar.gz.

File metadata

  • Download URL: jwt_manager-0.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.0

File hashes

Hashes for jwt_manager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c15278a377fab74f7c8a09a5e4ccd35b993cc125cbaa5bda5be8905951abb4f3
MD5 fd015d40435381b36332c695017f507e
BLAKE2b-256 423c6cbd7943e37ba576320322823359888bc54559cb6a25f3073b9bb9bf9738

See more details on using hashes here.

File details

Details for the file jwt_manager-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jwt_manager-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.0

File hashes

Hashes for jwt_manager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1282ddc23f4459dd69e78fa9ab8c550b52d730f3de43d2186da768cae48f6df
MD5 8d313fe877a17b2be85ecd91885ad428
BLAKE2b-256 e9c2b0d33137f493c37af3224d7e1fcc766c6a090a2c3eacee2f6290bfced309

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page