authenticate user on post request returns 403-regarding

29 views
Skip to first unread message

sabari rangan

unread,
Sep 18, 2016, 3:56:18 PM9/18/16
to Django users
i am using django.contrib.auth module for authentication system in my django rest framework app, when i post data i couldn't able to authenticate the user it return 403 response code . but during get request it works fine. i have attached the sessionid in cookies in both above. kindly help me with this i got stuck.

James Schneider

unread,
Sep 18, 2016, 4:04:58 PM9/18/16
to django...@googlegroups.com

On Sep 18, 2016 12:56 PM, "sabari rangan" <sabari....@gmail.com> wrote:
>
> i am using django.contrib.auth module for authentication system in my django rest framework app, when i post data i couldn't able to authenticate the user it return 403 response code . but during get request it works fine. i have attached the sessionid in cookies in both above. kindly help me with this i got stuck.
>

Can you post the relevant Django views for the GET and POST requests?

-James

sabari rangan

unread,
Sep 19, 2016, 8:25:18 AM9/19/16
to Django users
the view is

@api_view(['POST'])
def example(request):
return Response({'usernmae': request.user.username},status=status.HTTP_200_OK)


when i print the content of response object it shows
b'{"detail":"CSRF Failed: CSRF cookie not set."}'

it happens only when i set sessionid cookie in client side
Reply all
Reply to author
Forward
0 new messages