Decode and verify Amazon Cognito JWT tokens
Note: tested on Python >= 3.6, compatible with PEP-492 (async/await coroutines syntax)
Installation
Package works in two modes: synchronous - requests as http-client and asynchronous - aiohttp as http-client. In order to avoid installing unnecessary dependencies I separated installation flow into two modes:
- Async mode -
pip install cognitojwt[async] - Sync mode -
pip install cognitojwt[sync]
Usage
import cognitojwt
id_token = '<YOUR_TOKEN_HERE>'
REGION = '**-****-*'
USERPOOL_ID = 'eu-west-1_*******'
APP_CLIENT_ID = '1p3*********'
# Sync mode
verified_claims: dict = cognitojwt.decode(
id_token,
REGION,
USERPOOL_ID,
app_client_id=APP_CLIENT_ID, # Optional
testmode=True # Disable token expiration check for testing purposes
)
# Async mode
verified_claims: dict = await cognitojwt.decode_async(
id_token,
REGION,
USERPOOL_ID,
app_client_id=APP_CLIENT_ID, # Optional
testmode=True # Disable token expiration check for testing purposes
)
Note: if the application is deployed inside a private vpc without internet gateway, the application will not be able to download the JWKS file.
In this case set the AWS_COGNITO_JWSK_PATH environment variable referencing the absolute or relative path of the jwks.json file.
This project was originally forked from https://github.com/borisrozumnuk/cognitojwt
Metadata
Release files for clp-cognitojwt 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clp-cognitojwt-1.3.1.tar.gz | 3.6 kB | Without provenance | Details for clp-cognitojwt-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clp_cognitojwt-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for clp_cognitojwt-1.3.1-py3-none-any.whl |
Total release size: 9.1 kB
Release files / clp-cognitojwt-1.3.1.tar.gz
| Download URL | clp-cognitojwt-1.3.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0cd1796269ee77c6672902bb183ec50afb27f75715253895f70dfdee288b2cba
|
|
BLAKE2b-256 checksum How to use checksums |
51230b3c5098fada04df8a48b6acc04a1c4c29471d2ddfab5f844a8313dc1955
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.5
|
Release files / clp_cognitojwt-1.3.1-py3-none-any.whl
| Download URL | clp_cognitojwt-1.3.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
913fb3f755d052ff9db4b3938f4156caafccae0dafb29f9e156724bee4d1c91c
|
|
BLAKE2b-256 checksum How to use checksums |
7c46112e684cd79b6c2ffb8356cd9be9ca329c5321d9ca3eb1b2dec282961904
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.6.5
|
Security for clp-cognitojwt 1.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.