I’m using django-rest-interface to build an API. However, when I make a request through curl, say:
curl -u 'username:password' -X PUT --data "field=value" http://127.0.0.1:8080/resource/
and try to access the request.user in the get(), post(), put() or delete() method in the resource, I always get an error saying that I’m accessing AnonymousUser().
How can I authenticate to these methods?
EDIT:
I was able to fix this problem for me by adding request.user=self.user in the function dispatch() in the file views.py of django-rest-framework, right before handler(request, *args, **kwargs).
However, I’m not sure if this is the correct thing to do.
A neater way to handle this is by subclassing BasicAuthentication, as above. Although it are things like this that make me question django-rest-framework…