Skip to main content

A Python implementation of JSON Web Tokens (JWT) for authentication and authorization using a symmetric secret key and HMAC-SHA256.

Project description

JWT Authentication

A Python implementation of JSON Web Tokens (JWT) for authentication and authorization using a symmetric secret key and HMAC-SHA256.

Features

  • Generate JWT tokens with customizable expiration times
  • Validate JWT tokens and verify their integrity using a symmetric secret key and HMAC-SHA256
  • Extract user information (such as user ID) from JWT tokens

Installation

You can install the package via pip:

pip install my_jwt

Usage

from my_jwt import JWT

# Create a JWT instance with your secret key
secret_key = 'your_secret_key'
jwt = JWT(secret_key)

# Generate a token for a user
user_id = 'user123'
token = jwt.createToken(user_id)

# Validate a token
is_valid, message = jwt.validateToken(token)
if is_valid:
    print('Token is valid')
else:
    print(f'Token is invalid: {message}')

# Get the user ID from a token
user_id = jwt.getUserId(token)
print(f'User ID: {user_id}')

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

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

ft_jwt-0.0.2.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file ft_jwt-0.0.2.tar.gz.

File metadata

  • Download URL: ft_jwt-0.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for ft_jwt-0.0.2.tar.gz
Algorithm Hash digest
SHA256 a5a9425d27f2cf05e7111c5bc9a31f75fcc3a6c5ba21983defb0052b00a5b63a
MD5 8494dc95b39ba1e1419c799a3ce73c30
BLAKE2b-256 a5d23ed7008ed2c230f1da6c6dcf766229634d449c25f94172aaf20636c34849

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