如何为tastypie设置授权标头?

And*_*ran 2 python django curl tastypie

在请求中传递值作为参数时,它可以工作:

curl "http://localhost:8080/wordgame/api/v1/rounds/?username=test_user&api_key=12345678907a9cb56b7290223165e0a7c23623df&format=json"
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将值作为标头传递时,它不起作用.这导致401:

curl -H "Authorization: ApiKey test_user:12345678907a9cb56b7290223165e0a7c23623df" -H "Accept: application/json" http://localhost:8080/wordgame/api/v1/rounds/
Run Code Online (Sandbox Code Playgroud)

我正在使用Tastypie ApiKeyAuthentication

tom*_*son 6

假设用户名/密钥正确,您的标题看起来是正确的..

尝试github master分支中的版本,从PyPI安装的pip也不会接受我的授权头.

我这样做了:

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