Django REST framework no authentication details -
Django REST framework no authentication details -
i building out api using django rest framework, having problem authenticating request using basic authentication. testing purposes have view that, when called via post
, provided valid username/password user
model, should homecoming model provided id
, in case id=1018
curl -x post http://<my-url>/api/detail/1018 -u <username>:<password> {"detail": "authentication credentials not provided."}
get
requests work fine no authentication required. have been next rest framework tutorial. in each class have permission_classes = (permissions.isauthenticatedorreadonly, isownerorreadonly,)
and in permissions.py
from rest_framework import permissions class isownerorreadonly(permissions.basepermission): def has_object_permission(self, request, view, obj): # read permissions allowed request, # we'll allow get, head or options requests. if request.method in permissions.safe_methods: homecoming true # write permissions allowed owner of account. # have commented out , set homecoming true can test # more narrow downwards cause of error. #obj.owner.id == request.user.id homecoming true
i'm not sure if code issue, says credentials not provided, not credentials wrong.
ok after digging deeper docs, found caveat when deploying apache. turns out have add together line httpd.conf file.
django authentication django-rest-framework
Comments
Post a Comment