首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >django-oauth-toolkit在AWS Elasticbeanstalk上部署后出现'invalid client‘错误

django-oauth-toolkit在AWS Elasticbeanstalk上部署后出现'invalid client‘错误
EN

Stack Overflow用户
提问于 2018-02-20 05:42:51
回答 2查看 585关注 0票数 2

我在我的django/django-rest-framework应用程序中使用django-oauth-toolkit。当我在本地主机上以dev模式请求访问令牌时,它工作正常:

代码语言:javascript
复制
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‘错误:

代码语言:javascript
复制
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应用程序请求访问令牌。

EN

回答 2

Stack Overflow用户

发布于 2018-02-22 23:02:56

经过一些研究,我现在可以自己给出答案了:

我不得不在我的.ebextensions文件夹中的python.config中再添加一个命令:

代码语言:javascript
复制
...
container_commands:
  ...    
  03wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

在那之后,AWS允许传入的请求通过授权,我得到的响应没有错误。

票数 2
EN

Stack Overflow用户

发布于 2019-01-02 20:41:20

我也面临着同样的问题。这对我很有效:

代码语言:javascript
复制
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"}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48874619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档