我在我的django/django-rest-framework应用程序中使用django-oauth-toolkit。当我在本地主机上以dev模式请求访问令牌时,它工作正常:
dev@devComp:$ curl -X POST -d "grant_type=password&username=
<user_name>&password=<password>" -u"<client_id>:<client_secret>"
http://localhost:8000/o/token/
{"access_token": "fFySxhVjOroIJkD0IuEXr5WIhwdXg6", "expires_in":
36000, "token_type": "Bearer", "scope": "read write groups",
"refresh_token": "14vhyaCZbdLtu7sq8gTcFpm3ro9YxH"}但是,如果我从部署在AWS Elasticbeanstalk上的完全相同的应用程序请求访问令牌,我会收到'invalid client‘错误:
dev@devComp:$ curl -X POST -d "grant_type=password&username=
<user_name>&password=<password>" -u"<client_id>:<client_secret>"
http://my-eb-prefix.us-west-1.elasticbeanstalk.com/o/token/
{"error": "invalid_client"}请建议我如何摆脱此错误,并正常从部署在AWS的django应用程序请求访问令牌。
发布于 2018-02-22 23:02:56
经过一些研究,我现在可以自己给出答案了:
我不得不在我的.ebextensions文件夹中的python.config中再添加一个命令:
...
container_commands:
...
03wsgipass:
command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'在那之后,AWS允许传入的请求通过授权,我得到的响应没有错误。
发布于 2019-01-02 20:41:20
我也面临着同样的问题。这对我很有效:
curl -X POST -d "grant_type=password&username=<your-username>&password=<your-password>&client_id=<your-client id>&client_secret=<your-client secret>" http://your-domain/o/token/
{"access_token": "0BVfgujhdglxC7OHFh0we7gprlfr1Xk", "scope": "read write", "token_type": "Bearer", "expires_in": 36000, "refresh_token": "AwffMPzNXvghlkjhs8dpXk7gbhhjhljlldfE2nI"}https://stackoverflow.com/questions/48874619
复制相似问题