我在我的django / django-rest-framework应用程序中使用django-oauth-toolkit . 当我在localhost上以开发模式请求访问令牌时,它可以正常工作:
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中部署的绝对相同的应用程序请求访问令牌,则会收到“无效客户端”错误:
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 app请求访问令牌 .
2 回答
经过一番研究,我现在可以自己给出答案:
我不得不在
.ebextensions
文件夹中的python.config
添加一个命令:之后,AWS允许传入的请求通过授权,我得到的响应没有错误 .
我也面临同样的问题 . 这对我有用: