django-rest-multitoken
django-rest-multitoken copied to clipboard
Implementation of Django Rest Framework token authentication that maintains multiple tokens for each user.
Django Rest Multitoken
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.
Installation
Use pip:
pip install git+https://github.com/sunscrapers/django-rest-multitoken.git
Usage
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',
),
}
Endpoints
Login
Use this endpoint to obtain user authentication token.
POST
URL: /login/
-
request
-
data:
{{ User.USERNAME_FIELD }}passwordclient
-
-
response
-
status:
HTTP_200_OK(success) -
data:
auth_token
-
Logout
Use this endpoint to logout user and remove user authentication token.
POST
URL: /logout/
-
response
- status:
HTTP_200_OK(success)
- status:
Development
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
