Search code examples
pythondjangocurltastypie

How do I set the authorization header for tastypie?


When passing values as parameters in the request it works:

curl "http://localhost:8080/wordgame/api/v1/rounds/?username=test_user&api_key=12345678907a9cb56b7290223165e0a7c23623df&format=json"

However, it does not work when I try to pass the values in as headers. This results in a 401:

curl -H "Authorization: ApiKey test_user:12345678907a9cb56b7290223165e0a7c23623df" -H "Accept: application/json" http://localhost:8080/wordgame/api/v1/rounds/

I am using Tastypie ApiKeyAuthentication


Solution

  • Your header looks correct assuming the username/key are right..

    Try the version from the github master branch, the one that pip installed from PyPI wouldn't accept the authorization header for me either.

    I did this:

    pip install https://github.com/toastdriven/django-tastypie/tarball/master --upgrade