Implementation of Django Rest Framework token authentication that maintains multiple tokens for each user.
Currently the project is still under development. It was extracted from djoser library. Original draft version is available here.
Developed by SUNSCRAPERS with passion & patience.
Use pip:
pip install git+https://github.com/sunscrapers/django-rest-multitoken.git
Add multitoken
app to INSTALLED_APPS
:
INSTALLED_APPS = (
'django.contrib.auth',
(...),
'rest_framework',
'multitoken',
(...),
)
Configure urls.py
:
urlpatterns = patterns('',
(...),
url(r'^auth/', include('multitoken.urls')),
)
Set up Django Rest Framework authentication strategy to multitoken.authentication.TokenAuthentication
:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'multitoken.authentication.TokenAuthentication',
),
}
Use this endpoint to obtain user authentication token.
URL: /login/
-
request
-
data:
{{ User.USERNAME_FIELD }}
password
client
-
-
response
-
status:
HTTP_200_OK
(success) -
data:
auth_token
-
Use this endpoint to logout user and remove user authentication token.
URL: /logout/
-
response
- status:
HTTP_200_OK
(success)
- status:
To start developing on django-rest-multitoken, clone the repository:
$ git clone [email protected]:sunscrapers/django-rest-multitoken.git
In order to run the tests create virtualenv, go to repo directory and then:
$ pip install -r requirements-test.txt
$ cd testproject
$ ./manage.py migrate
$ ./manage.py test