22👍
In my case token authentication was working fine on development server and not on Apache. The reason was exactly the missing WSGIPassAuthorization On
6👍
see your settings.py, if you have
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
in REST_FRAMEWORK like this, it will Authenticate each time when you post.
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)}
so, delete it.
- How can I sort by the id of a ManyToManyField in Django?
- Running multiple sites on the same python process
- Django/Python: generate pdf with the proper language
0👍
In my case, I used a permissions.IsAuthenticatedOrReadOnly
permission class in my viewset, but sending a post request without login:
class MemberViewSet(viewsets.ModelViewSet):
queryset = Member.objects.all()
serializer_class = MemberSerializer
permission_classes = (
permissions.IsAuthenticatedOrReadOnly,
)
@list_route(methods=['post'])
def check_activation_code(self, request):
# my custom action which do not need login
# I met the error in this action
do_something()
So the permission checking for that permission class is failed.
Everything goes well after I remove the IsAuthenticatedOrReadOnly
permission class.
- Display query string values in django templates
- Login_required decorator in django
- Django non primary_key AutoField
- Django admin page and JWT
- Django request.user.is_authenticated is always true?
Source:stackexchange.com