using permission required
I am trying to use permission required decorator using authorization header.And it always gives me 302 error. although my user has permission for it.Kindly help I am beginner to django. Here is my code @permission_required('access_admin', login_url=None) @permission_classes((IsAuthenticated,)) @api_view(['POST','GET']) def actionLibrary(request): if request.method == 'GET': print(request.user.has_perm("api.access_admin")) #it print true if I remove permission_required decorator queryset=ActionLibrary.objects.all() serializer=ActionLibrarySerailizer(queryset,many=True) return Response(serializer.data) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7952f118-107c-489b-a9e0-a94cc3441337%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django token base authentication using python
Hi I am trying to build an authentication system. I have added following in my setting.py file REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ), 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination' } And I also added decorators in my each api functional views as following @permission_classes((IsAuthenticated,)) Now I am making request to api using token so some them are accessible but some get unauthorized.And these api which get unathorized are random mean not a particular api get unauthorized. Am I missing something?Please help me out here! Thanks Akash -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e8fd147e-6090-4805-9369-127dc3329485%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Authorization not working on production server
Hi, I am building authorization in django framework using python.. The problem is that my code is working fine on local server but when I run the same in production it returns "Anonymous User" Am I doing it right? if request.user.has_perm('auth.access_admin') ""whole code"" else: return Response({'error': 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED) My request.user.has_perm return false because request.user is Anonymous.I also try to return my request.user.username it is also coming blank.Please help me out! Thanks Akash -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cf25f56b-1fc6-45df-bf4b-ba0b01729b04%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.