2

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

Peterpanx
  • 84
  • 2
  • 11
Andrew Halloran
  • 1,518
  • 1
  • 14
  • 16
  • Which version of tastypie are you using? And can you run the same verbose (-v). If it doesn't help I suggest some debugging with an IDE and see what happens on the is_authenticated method of the ApiKeyAuthentication. – Alex Botev Jul 28 '12 at 22:18

2 Answers2

6

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

tomwilson
  • 1,014
  • 10
  • 12
0

Sorry to add what is pretty much a duplicate answer but I can't comment yet. I had the same issue and as mentioned by the other answer I had to update to the latest code to get this to work since it was added after the current release.

One thing to note is that by default the documentation on readthedocs seems to track the latest development version rather than a specific release. To change this you can click on the "brought to you be read the docs" image at the bottom of the screen and select the version you are using.

Roarster
  • 804
  • 1
  • 8
  • 13