93a3de57ff
+ Revised README.md. + AutoPEP8 rest_auth python files. |
||
---|---|---|
rest_auth | ||
.gitignore | ||
AUTHORS | ||
LICENSE | ||
MANIFEST.in | ||
README.md | ||
setup.py |
django-rest-auth
Since the introduction of django-rest-framework, Django apps have been able to serve up app-level REST API endpoints. As a result, we saw a lot of instances where developers implemented their own REST registration API endpoints here and there, snippets, and so on. We aim to solve this demand by providing django-rest-auth, a set of REST API endpoints to handle User Registration and Authentication tasks. By having these API endpoints, your client apps such as AngularJS, iOS, Android, and others can communicate to your Django backend site independently via REST APIs for User Management. Of course, we'll add more API endpoints as we see the demand.
Features
- User Registration with activation
- Login/Logout
- Retrieve/Update the Django User & user-defined UserProfile model
- Password change
- Password reset via e-mail
Installation
-
This project needs the following packages
django-registration>=1.0
djangorestframework>=2.3.13
django-rest-swagger>=0.1.14
-
Install this package.
-
Add rest_auth app to INSTALLED_APPS in your django settings.py
INSTALLED_APPS = (
..., 'rest_auth',
)
-
This project depends on django-rest-framework library, therefore the following REST_FRAMEWORK settings needs to be entered in your Django settings.py::
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated' )
}
-
Lastly, this project accepts the following Django setting values. You can set the UserProfile model and/or create your own REST registration backend for django-registration.
REST_REGISTRATION_BACKEND = 'rest_auth.backends.rest_registration.RESTRegistrationView'
REST_PROFILE_MODULE = 'accounts.UserProfile'
-
You're good to go now!
API endpoints without Authentication
-
/rest_accounts/register/ - POST
Parameters
username, password, email, first_name, last_name
-
/rest_accounts/password/reset/ - POST
Parameters
email
-
/rest_accounts/password/reset/confirm/{uidb64}/{token}/ - POST
Django URL Keywords
uidb64, token
Parameters
new_password1, new_password2
-
/rest_accounts/login/ - POST
Parameters
username, password
-
/rest_accounts/verify-email/{activation_key}/ - GET
Django URL Keywords
activation_key
API endpoints with Authentication
-
/rest_accounts/logout/ - GET
-
/rest_accounts/user/ - GET & POST
GET Parameters
POST Parameters
user as dictionary with id, email, first_name, last_name
Ex) "user": {"id": 1, "first_name": "Person", "last_name": "2"}
user-defined UserProfile model fields
-
/rest_accounts/password/change/ - POST
Parameters
new_password1, new_password2