Skip to main content
https://github.com/bekindsoft/django-cognito-jwt2/workflows/Python%20Tests/badge.svg http://codecov.io/github/LabD/django-cognito-jwt/coverage.svg?branch=master https://img.shields.io/pypi/v/django-cognito-jwt2.svg Documentation Status

Django Cognito JWT2

An Authentication backend for Django Rest Framework for AWS Cognito JWT tokens

Installation

pip install django-cognito-jwt2

Usage

Add the following lines to your Django settings.py file:

COGNITO_AWS_REGION = '<aws region>' # 'eu-central-1'
COGNITO_USER_POOL = '<user pool>'   # 'eu-central-1_xYzaq'
COGNITO_AUDIENCE = '<client id>'

(Optional) If you want to cache the Cognito public keys between requests you can enable the COGNITO_PUBLIC_KEYS_CACHING_ENABLED setting (it only works if you have the Django CACHES setup to anything other than the dummy backend).

COGNITO_PUBLIC_KEYS_CACHING_ENABLED = True
COGNITO_PUBLIC_KEYS_CACHING_TIMEOUT = 60*60*24  # 24h caching, default is 300s

Also update the rest framework settings to use the correct authentication backend:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        ...
        'django_cognito_jwt2.JSONWebTokenAuthentication',
        ...
    ],
    ...
 }

Be sure you are passing the ID Token JWT from Cognito as the authentication header. Using the Access Token will work for authentication only but we’re unable to use the get_or_create_for_cognito method with the Access Token.

(Optional) If you want to use a different user model then the default DJANGO_USER_MODEL you can use the COGNITO_USER_MODEL setting.

COGNITO_USER_MODEL = "myproject.AppUser"

Metadata

Release files for django-cognito-jwt2 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cognito-jwt2 0.2.0
File Size Uploaded Provenance Actions
django-cognito-jwt2-0.2.0.tar.gz 5.6 kB With provenance Details for django-cognito-jwt2-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-cognito-jwt2 0.2.0
File Interpreter ABI Platform Actions
django_cognito_jwt2-0.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for django_cognito_jwt2-0.2.0-py2.py3-none-any.whl

Total release size: 11.3 kB

Release files / django-cognito-jwt2-0.2.0.tar.gz

Download URL django-cognito-jwt2-0.2.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1ec9f4c77454bd259074465831a232273c42916f2e2006e366c7ca9cdecd062b
BLAKE2b-256 checksum
How to use checksums
764d303dfc0ef42d718a014265d5d93eb501b04c751dfaa9dd70ce8364466c67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2025.

Transparency log

Release files / django_cognito_jwt2-0.2.0-py2.py3-none-any.whl

Download URL django_cognito_jwt2-0.2.0-py2.py3-none-any.whl
Size 5.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3e7f791129b9c1fa6b00a009641c0e687e45df275afa4acaa4bce0aff0de1749
BLAKE2b-256 checksum
How to use checksums
31fd37906741b53e96995e29b501ba123457e07534a66bf5dabfd8e305d2e13d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2025.

Transparency log

Security for django-cognito-jwt2 0.2.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django-cognito-jwt2-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 8, 2025.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page