Skip to content

Commit

Permalink
Merge pull request #32 from S1M0N38/master
Browse files Browse the repository at this point in the history
access-control login API with obtain_auth_token method
  • Loading branch information
shabda committed Aug 11, 2018
2 parents e3de4ac + 345a58c commit d3a26db
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion docs/access-control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Add a view and connect it to urls.
class LoginView(APIView):
permission_classes = ()
def post(self, request,):
username = request.data.get("username")
password = request.data.get("password")
Expand Down Expand Up @@ -229,6 +229,19 @@ POST with a incorrect username and password, and you will get a response like th
"error": "Wrong Credentials"
}
Another way to create this login endpoint is using :code:`obtain_auth_token` method provide by DRF

.. code-block:: python
# in urls.py
# ...
from rest_framework.authtoken import views
urlpatterns = [
path("login/", views.obtain_auth_token, name="login"),
# ...
]
Fine grained access control
-----------------------------
Expand Down

0 comments on commit d3a26db

Please sign in to comment.