【发布时间】:2018-07-30 04:29:25
【问题描述】:
我在 django/django-rest-framework 应用程序中使用 django-oauth-toolkit。当我在本地主机上以开发模式请求访问令牌时,它可以正常工作:
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 应用程序请求访问令牌。
【问题讨论】:
-
我不确定它是否相关,但您的
ALLOWED_HOSTS中有my-eb-prefix.us-west-1.elasticbeanstalk.com吗? -
是的,它在我的 ALLOWED_HOSTS 中
标签: django amazon-web-services amazon-ec2 django-rest-framework django-oauth