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')

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.7.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

simple_jwt_decode-0.7.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file simple_jwt_decode-0.7.0.tar.gz.

File metadata

  • Download URL: simple_jwt_decode-0.7.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.0

File hashes

Hashes for simple_jwt_decode-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e2533fc6272da07e0c966409a51bedf0bbecf4ed4ce1d13b7d7013e65bcbeafd
MD5 dd2e9c861b91fdd4c2692ea5f7d5ce57
BLAKE2b-256 e451b0e3e5bfa35cb2528589bc51b6841e05af3f238b5264570d26f6c1f80018

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for simple_jwt_decode-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a0d1e75b30a692c3b54ef7fdd433d817610bc90c3ae4c22965d5b7ec1a77c0b
MD5 21861bae8753e94ef0aba093959bf0ff
BLAKE2b-256 08048e6c553d13eceaed20c685144dd44942cf60cea51d7b5eb9c97f4f379ce7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page