django-token
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.
Installing
Install from pip
sudo pip install django_token
Add the middleware to your MIDDLEWARE_CLASSES
MIDDLEWARE_CLASSES = (
# Other middleware
'django_token.middleware.TokenMiddleware',
)
Add the authenticaton backend to your AUTHENTICATION_BACKENDS
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'django_token.backends.TokenBackend'
)
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 manage.py 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(
"http://myserver.com/api/stuff",
headers={"Authorization": "token r454f2529f2cd27e1722e67a624b2b18335e6c21"}
)
Metadata
Release files for django-token 0.1.3
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 |
|---|---|---|---|---|
| django-token-0.1.3.tar.gz | 4.5 kB | Without provenance | Details for django-token-0.1.3.tar.gz |
Release files / django-token-0.1.3.tar.gz
| Download URL | django-token-0.1.3.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a4169a03035bd35c8d509cbead15548ccf549fe0c92a9d3924ca0ab4291de21
|
|
BLAKE2b-256 checksum How to use checksums |
e6c9a64a6ae865d235d7df5790cab74fb7ea5bd0a46f95a82f0f985017052563
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8
|
Security for django-token 0.1.3
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.