Skip to main content

This library let you to authenticate an specific user on DRF based on the JWT Token returned by Auth0 Javascript libraries.

Project description


This library let you to authenticate an specific user on DRF based on the JWT Token returned by Auth0 Javascript libraries.



  1. Using pip to install current release:
pip install rest_framework_auth0
  1. Using pip to install development version:
pip install git+

Quick start

  1. Make sure django.contrib.auth in on INSTALLED_APPS setting, otherwise add it by your own:

This will allow us to login as an specific user as well as auto-creating users when they don't exist

  1. Add rest_framework_auth0 to your INSTALLED_APPS setting:
  1. Add Auth0JSONWebTokenAuthentication in your DEFAULT_AUTHENTICATION_CLASSES located at from your project:
  1. Add your CLIENTS & MANAGEMENT_API settings in your file:
# Import cryptography libraries
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
# Read the your Auth0 client PEM certificate
certificate_text = open('rsa_certificates/certificate.pem', 'rb').read()
certificate = load_pem_x509_certificate(certificate_text, default_backend())
# Get your PEM certificate public_key
certificate_publickey = certificate.public_key()
AUTH0 = {
  'CLIENTS': {
      'default': {
          'AUTH0_ALGORITHM': 'RS256',  # default used in Auth0 apps
          'PUBLIC_KEY': certificate_publickey',
  # Management API - For roles and permissions validation
  1. Add the Authorization Header to all of your REST API request, prefixing Bearer to your token(default in common REST clients & Postman):
Authorization: Bearer <AUTH0_GIVEN_TOKEN>
  1. That's it, now only your Auth0 users can request data to your DRF endpoints
NOTE: In order to get the token authentication, the 'django.contrib.auth' app models migrations must be applied(python migrate).

Use cases

Sample Project

A sample project can be found here

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for rest-framework-auth0, version 0.6.4
Filename, size File type Python version Upload date Hashes
Filename, size rest_framework_auth0-0.6.4-py3-none-any.whl (13.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size rest-framework-auth0-0.6.4.tar.gz (12.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page