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.9.0.tar.gz
.
File metadata
- Download URL: simple_jwt_decode-0.9.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc46c5d8ea911babfb78e556241eb287eb143e045251e87131078457f4626500 |
|
MD5 | 4ee63974da477dd03868c496e8c8a8bc |
|
BLAKE2b-256 | 1a3a233a7c82ab7e2a29770d8a8ec27c72b943a5507ac3603664fdb81f0a887b |
File details
Details for the file simple_jwt_decode-0.9.0-py3-none-any.whl
.
File metadata
- Download URL: simple_jwt_decode-0.9.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea19b1719b1bae7c71bb440b9e6c4263da8a0a33954ea53193db7ad89a337f4 |
|
MD5 | 204fd409c73c333758af864afbe0f439 |
|
BLAKE2b-256 | 7a008884cd037a949404d60e8316410fdb7d3071008f439612dd738116a031e3 |