Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahattincinic/drf-expiration-token-authentication
Expiration Token Authentication For Django Rest Framework
https://github.com/bahattincinic/drf-expiration-token-authentication
Last synced: about 1 month ago
JSON representation
Expiration Token Authentication For Django Rest Framework
- Host: GitHub
- URL: https://github.com/bahattincinic/drf-expiration-token-authentication
- Owner: bahattincinic
- Created: 2014-07-08T20:07:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-22T05:04:38.000Z (over 10 years ago)
- Last Synced: 2023-04-27T16:49:00.351Z (over 1 year ago)
- Language: Python
- Size: 188 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
DRF Expiration Token Authentication
====================
Expiration Token Authentication For Django Rest Framework[![Build Status](https://travis-ci.org/bahattincinic/drf-expiration-token-authentication.svg?branch=master)](https://travis-ci.org/bahattincinic/drf-expiration-token-authentication)
Requirements
------* Python (2.6, 2.7, 3.2, 3.3, 3.4)
* Django (1.4, 1.3, 1.5, 1.6,)Installation
------Install using `pip`...
pip install -e [email protected]:bahattincinic/drf-expiration-token-authentication.git
Usage
------
Add `TOKEN_AUTHENTICATION` to your settings.TOKEN_AUTHENTICATION = {
# default: False
'is_expired': True,
# in days
'expiration_time': 30
}
INSTALLED_APPS = (
...
'rest_framework',
'rest_framework.authtoken',
)
Add `Authentication Backend` to your settings.
REST_FRAMEWORK = {
....svg?branch=master
DEFAULT_AUTHENTICATION_CLASSES: (
'rest_expiration_token.authentication.ExpiringTokenAuthentication'
...
)
}`ExpiringTokenAuthentication` To manually add
from rest_framework.views import APIView
from rest_expiration_token.authentication import ExpiringTokenAuthentication
class TestView(APIView):
authentication_classes = (ExpiringTokenAuthentication,)
...Add `Authentication View` to your urls
from rest_expiration_token.views import TokenAuthenticationView
urlpatterns = patterns('',
...
url(r'^auth-token/$', TokenAuthenticationView.as_view()),
)Sample Response
------------------
curl -X POST -H "Content-Type: application/json" -d '{"username":"bahattincinic","password":"123456"}' http://localhost:8000/auth-token/
{"expiration_date": "2014-07-25T20:57:01.413Z", "token": "acf45a335d83074a5d7e8d4a09a4d2ba5d52de41"}