Skip to main content

Simple Python Package for decoding JWT claims and checking if its expired. No verification of signatures.

Project description

Simple JWT

PyPI version


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-expiry or -e: Only check if the token is expired
  • --raw or -r: Print raw decoded data without formatting

Example:

jwt <token>

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

simple_jwt_decode-0.10.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simple_jwt_decode-0.10.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

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

Hashes for simple_jwt_decode-0.10.0.tar.gz
Algorithm Hash digest
SHA256 f3ee891c67e51e27e0ac9f7efa2f2247cf87ab725d0223f727fd63fc029a874c
MD5 afd8f6ed3b5eb7b72e506655ca196843
BLAKE2b-256 0bafcaa3ae8bb961c47fd388bf02ace410e230ba39b008f992acb827a1a82cc5

See more details on using hashes here.

File details

Details for the file simple_jwt_decode-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_jwt_decode-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfd144499881db52ed7636afc156bf17fb4b8fab33ed6220ad4bf86723fe9a2c
MD5 2c24892a9cdfa5aa339151266a6fb5eb
BLAKE2b-256 4c6db1d157ffef77c2df86f8836002403eee6daa6886c6b7beee08201b3d2cef

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