django-rest-framework Token Authentication With Django Rest Framework Using CURL


If a curl would be run against this endpoint

curl http://localhost:8000/auth/    
op : {"detail": "Authentication credentials were not provided."}%

would return a 401 error UNAUTHORIZED

but in case we get a token before:

curl -X POST -d "user=Pepe&password=aaaa"  http://localhost:8000/
{"token": "f7d6d027025c828b65cee5d38240aec60dffa150", "detail": "POST answer"}%

and then we put that token into the header of the request like this:

curl http://localhost:8000/auth/ -H 'Authorization: Token f7d6d027025c828b65cee5d38240aec60dffa150'

op: {"detail": "I suppose you are authenticated"}%