Simple Python Package for decoding JWT claims and checking if its expired. No verification of signatures.
Project description
Simple JWT
Why?
I created this package because I found that I often needed to see the cliams of a JWT token and wether it was expired or not. I didn't need to verify it the signatures. I wanted a package to check if the token was expired, so I could refresh my token or take other actions based off that. Most other packages seemed to require verified signatures or would throw errors if a key was not provided. Just needed a simple package to get the cliams info and if the token was expired. Simple JWT.
Table of Contents
Installation
pip install simple-jwt-decode
Usage
Decode
from simple_jwt import jwt
jwt.decode(token)
Should return at dict that looks similar to the following:
{'headers': {'alg': 'HS512'}, 'claims': {'exp': 1681337256, 'iat': 1681333656, 'sid': '15307164276', 'aid': '8652598085', 'cid': '50430702', 'type': 'r'}, 'signature': 'jmFoOydgYnL8AqmgnLSFU2l_E6q3pnPHh7ss-g7xKO7tLD_JY8vZR3O-cthNInFzi9G2M3t2boRzMTatlbsZ7Q'}
Expired
from simple_jwt import jwt
expired = jwt.is_expired(token)
if (expired):
print('Your JWT token is expired! Oh no! Better get a new one')
else:
print('Your JWT token is not expired; No need to refesh at the moment')
CLI Usage
You can also use the command-line interface to decode JWT tokens:
jwt <token>
This will display the decoded token headers, claims, and signature, as well as whether the token is expired.
Options:
--check-expiryor-e: Only check if the token is expired--rawor-r: Print raw decoded data without formatting
Example:
jwt <token>
License
simple-jwt is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_jwt_decode-0.10.0.tar.gz.
File metadata
- Download URL: simple_jwt_decode-0.10.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ee891c67e51e27e0ac9f7efa2f2247cf87ab725d0223f727fd63fc029a874c
|
|
| MD5 |
afd8f6ed3b5eb7b72e506655ca196843
|
|
| BLAKE2b-256 |
0bafcaa3ae8bb961c47fd388bf02ace410e230ba39b008f992acb827a1a82cc5
|
File details
Details for the file simple_jwt_decode-0.10.0-py3-none-any.whl.
File metadata
- Download URL: simple_jwt_decode-0.10.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfd144499881db52ed7636afc156bf17fb4b8fab33ed6220ad4bf86723fe9a2c
|
|
| MD5 |
2c24892a9cdfa5aa339151266a6fb5eb
|
|
| BLAKE2b-256 |
4c6db1d157ffef77c2df86f8836002403eee6daa6886c6b7beee08201b3d2cef
|