Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Simple token based authentication for Django

Project description


Simple token based authentication for Django.

This draws inspiration from the Django Rest Framework token based authentication scheme but allows you to use it without using Django Rest Framework.


Install from pip

sudo pip install django_token

Add the middleware to your MIDDLEWARE_CLASSES

    # Other middleware

Add the authenticaton backend to your AUTHENTICATION_BACKENDS


Creating tokens

You can create tokens for users using whatever workflow you'd like.

from django_token.models import Token

token = Token.objects.create(user=myuser)

If you REALLY want to reset all the tokens in your database, you can use the reset_tokens management command.

python reset_tokens

This is useful when you've just installed django-token, but is otherwise dangerous :)

Token in headers

The user's token should be passed in on every request in the HTTP authorization header.

Using requests

import requests
response = requests.get(
    headers={"Authorization": "token r454f2529f2cd27e1722e67a624b2b18335e6c21"}

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 django-token, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size django-token-0.1.3.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

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