Missing Authorization header

314 views
Skip to first unread message

Glenn Pierce

unread,
Oct 20, 2016, 1:53:04 PM10/20/16
to Django REST framework
Hi I am just getting started with django_rest_framework and I have I am trying to add a rest api to an existing site.

I have managed to implement a a function to get the token.

ie

curl -X POST -d "username=*****&password=*****"  http://***.com/api-token-auth/

{"token":"549a12a6d4d2dc634e8a1bfbd73fa0dd9ab46890"}

However, when calling one on my methods to get data I get

curl -X GET https://************.com/pages/get_pages/ -H 'HTTP_AUTHORIZATION: Token 549a12a6d4d2dc634e8a1bfbd73fa0dd9ab46890'
{"detail":"Authentication credentials were not provided."}


On the server I inherited TokenAuthentication like so

class MyRestAuthentication(TokenAuthentication):
    def authenticate(self, request):
        print "MyRestAuthentication", request.META.items()
        auth = get_authorization_header(request).split()
        print auth
        return super(MyRestAuthentication, self).authenticate(request)


I am printing out the headers but I don't see the HTTP_AUTHORIZATION header or any with my token.

What and I missing ?

Thanks

Glenn Pierce

unread,
Oct 20, 2016, 2:56:13 PM10/20/16
to Django REST framework
Ah I had to add

WSGIPassAuthorization On

to Apache

I thought I had done that but forgot.
Reply all
Reply to author
Forward
0 new messages