0

I am registering the user by using this post , In this case successfully i am creating the user.

After above step, I enabled token authentication by using this post, but the main problem is when i perform registration operation it is showing "detail": "Authentication credentials were not provided." this error.

Here i don't need authentication checking for user registration, need authentication checking for remaining apis.

Can anyone please help me out how to disable authentication for user registration.

Thanks in advance

Community
  • 1
  • 1
Anjaneyulu Battula
  • 1,910
  • 16
  • 33
  • My i know why down vote. there is no direct question in SO on this, and i checked about this in Django Rest framework documentation, there is no direct solution for this. If you find any direct link for my question, Please add in comment. – Anjaneyulu Battula Dec 09 '15 at 15:34

1 Answers1

1

Depending on how you want your endpoint to be accessed and the level of publicity you can use 1 of 2 permissions.

Either AllowAny or IsAuthenticatedOrReadOnly

AllowAny will allow for anyone accessing each of the methods you've defined for the viewset.

IsAuthenticatedOrReadOnly will, by default, allow anyone to use the safe http methods GET, HEAD or OPTIONS on your endpoint but in order to POST, PUT/PATCH or DELETE you would need to be authenticated.

You add these to each of your endpoints for fine grained control

from rest_framework import permissions

class MyViewSet(viewsets.GenericViewSet):
    permissions_classes = (permissions.AllowAny, )
Henrik Andersson
  • 45,354
  • 16
  • 98
  • 92