授权凭证剥离--- django,弹性豆串,oauth [英] Authorization Credentials Stripped --- django, elastic beanstalk, oauth
问题描述
我用:
curl -X POST -dclient_id = YOUR_CLIENT_ID& client_secret = YOUR_CLIENT_SECRET& grant_type = password& username = YOUR_USERNAME& password = YOUR_PASSWORDhttp:// localhost:8000 / oauth2 / access_token /
和
curl -H授权:承载<你的访问令牌>本地主机上的http:// localhost:8000 / api /
与成功的结果符合文档。 / p>
当将其推送到现有的AWS弹性beanstalk实例时,我收到了:
{detail:未提供验证凭据。 }
我现在使用的方法略有不同。只要env变量没有改变,sahutchi的解决方案工作,汤姆迪金指出。我在EB里面挖了一下,找到wsgi.conf模板所在的位置,并在那里添加了WSGIPassAuthorization On选项。
命令:
WSGIPassAuthorization:
命令:sed -i.bak'/ WSGIScriptAlias / a WSGIPassAuthorization在'config.py
cwd:/ opt / elasticbeanstalk / hooks
即使更改环境变量,这将始终有效。我希望你觉得有用。
I implemented a REST api in django with django-rest-framework and used oauth2 for authentication.
I tested with:
curl -X POST -d "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=password&username=YOUR_USERNAME&password=YOUR_PASSWORD" http://localhost:8000/oauth2/access_token/
and
curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/
on localhost with successful results consistent with the documentation.
When pushing this up to an existing AWS elastic beanstalk instance, I received:
{ "detail" : "Authentication credentials were not provided." }
I use a slightly different approach now. sahutchi's solution worked as long as env variables were not changed as Tom dickin pointed out. I dug a bit deeper inside EB and found out where the wsgi.conf template is located and added the "WSGIPassAuthorization On" option there.
commands:
WSGIPassAuthorization:
command: sed -i.bak '/WSGIScriptAlias/ a WSGIPassAuthorization On' config.py
cwd: /opt/elasticbeanstalk/hooks
That will always work, even when changing environment variables. I hope you find it useful.
这篇关于授权凭证剥离--- django,弹性豆串,oauth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!