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')
License
simple-jwt
is distributed under the terms of 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
Built Distribution
File details
Details for the file simple_jwt_decode-0.5.0.tar.gz
.
File metadata
- Download URL: simple_jwt_decode-0.5.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad6028acd9e762c2c0917d49572c5440319e88828fa9a6b632ca06e25eaf008 |
|
MD5 | 485969e1afabc861831228f7910f26ba |
|
BLAKE2b-256 | a082b0ee6b8033548a2b2d5cc157a7a40b53368d9ee4daee9236869aa613f3fa |
File details
Details for the file simple_jwt_decode-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: simple_jwt_decode-0.5.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a683f0f229be64f9a055d3c6b611a294f74778b0b8d63a925db98378f379fc86 |
|
MD5 | b13e1b0f5cac9299f400f74f89106b25 |
|
BLAKE2b-256 | 7121e85e0f32be8eb6fa8b890faabde9d631d2ef3e19ef48668826342860e33a |