This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca81820
commit 85f59dc
Showing
4 changed files
with
78 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
REST API | ||
-------- | ||
To use the REST API, *djangorestframework* must be installed:: | ||
|
||
pip install djangorestframework | ||
|
||
Add rest framework to installed apps:: | ||
|
||
INSTALLED_APPS = ( | ||
... | ||
'rest_framework', | ||
'rest_framework.authtoken', | ||
'nopassword', | ||
... | ||
) | ||
|
||
Add *TokenAuthentication* to default authentication classes:: | ||
|
||
REST_FRAMEWORK = { | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
'rest_framework.authentication.TokenAuthentication', | ||
) | ||
} | ||
|
||
Add urls to your *urls.py*:: | ||
|
||
urlpatterns = patterns('', | ||
... | ||
url(r'^api/accounts/', include('nopassword.rest.urls')), | ||
... | ||
) | ||
|
||
You will have the following endpoints available: | ||
|
||
- `/api/accounts/login/` (POST) | ||
- username | ||
- next (optional, will be returned in ``/api/accounts/login/code/`` to be handled by the frontend) | ||
- Sends a login code to the user | ||
- `/api/accounts/login/code/` (POST) | ||
- code | ||
- Returns ``key`` (authentication token) and ``next`` (provided by ``/api/accounts/login/``) | ||
- `/api/accounts/logout/` (POST) | ||
- Performs logout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters