Skip to main content

Rest Auth Multitoken

django-rest-auth is a great package for authentication with django, however it lacks the possibility of allowing a user to have multiple auth tokens. Thus a user has a single token shared across all his clients, and when he logs out from one client he gets logged out of all his clients.

rest-auth-multitoken solves this problem by adding multiple tokens support for a single user to django-rest-auth.

Installation

install rest-auth-multitoken

> pip install rest-auth-multitoken

Then in django's settings.py:

add it to INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    ...
    'rest_auth_multitoken',
    ...
]

add it to REST_FRAMEWORK's config:

# settings.py

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        ...
        'rest_auth_multitoken.utils.MultiTokenAuthentication',
        ...
    ),
}

configure django-rest-auth to use rest-auth-multitoken:

# settings.py
REST_AUTH_TOKEN_CREATOR = 'rest_auth_multitoken.utils.multitoken_create'
REST_AUTH_TOKEN_MODEL = 'rest_auth_multitoken.models.Token'

Finally include the new MultitokenLogoutView and MultitokenRegisterView in urls.py, just before django-rest-auth's urls:

# urls.py
from rest_auth_multitoken.views import (
    MultitokenRegisterView,
    MultitokenLogoutView,
)



urlpatterns = [
    ...
    path('api/auth/logout/', MultitokenLogoutView.as_view()),
    path('api/auth/registration/', MultitokenRegisterView.as_view())

    path('api/auth/registration/', include('rest_auth.registration.urls'))
    path('api/auth/', include('rest_auth.urls')),
    ...
]

Now everytime a user logs in he'll get a new token, even if he's logged in from another client.

Metadata

Release files for rest-auth-multitoken 0.2.2

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

Source distribution (sdist)

Source distribution for rest-auth-multitoken 0.2.2
File Size Uploaded Provenance Actions
rest-auth-multitoken-0.2.2.tar.gz 4.9 kB Without provenance Details for rest-auth-multitoken-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rest-auth-multitoken 0.2.2
File Interpreter ABI Platform Actions
rest_auth_multitoken-0.2.2-py3-none-any.whl Python 3 none any Details for rest_auth_multitoken-0.2.2-py3-none-any.whl

Total release size: 10.3 kB

Release files / rest-auth-multitoken-0.2.2.tar.gz

Download URL rest-auth-multitoken-0.2.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8a6310e96e684c70ac1959ae9bf70dd95e82c70bcd4b9753d9cafb661be5d2a3
BLAKE2b-256 checksum
How to use checksums
cdefc9bd4fb100debeca19498c9d8f2ffc00c2772eae202b60922c079004410f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.0 Linux/5.4.0-58-generic

Release files / rest_auth_multitoken-0.2.2-py3-none-any.whl

Download URL rest_auth_multitoken-0.2.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
700f3376520e2059805250c7982ea1ea324d34f9afdf37e9a00d2b65718508d6
BLAKE2b-256 checksum
How to use checksums
addadbb6ae7b9d8405ab73f6d02d0b0d3e170ac5a0af24bd40a23e5ff92d6599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.0 Linux/5.4.0-58-generic

Security for rest-auth-multitoken 0.2.2

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.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files No 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