A simple Python utility for generating JSON Web Tokens (JWT) using RS256 algorithm.
- Generate JWT tokens with customizable claims
- Support for RS256 signing algorithm
- Configurable subject, name, and API key claims
- Includes timestamp (iat) in token payload
- Python 3.x
- PyJWT (2.8.0)
- cryptography (41.0.4)
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Copy
config.template.py
toconfig.py
and fill in your configuration:cp config.template.py config.py
The main script generate_jwt.py
provides a function to generate JWT tokens. You can either import the function in your code or run the script directly:
from generate_jwt import generate_jwt
token = generate_jwt(
subject="your-subject",
name="your-name",
x_api_key="your-api-key",
private_key="your-private-key"
)
Or run directly from command line:
python generate_jwt.py
Edit config.py
to set your default values for:
SUBJECT
: The subject claim for the tokenNAME
: The name claim for the tokenX_API_KEY
: Your API keyPRIVATE_KEY
: Your RSA private key for signingALGORITHM
: The signing algorithm (defaults to RS256)