首页 文章

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

提问于
浏览
2

我在我的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 回答

  • 0

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

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

    ...
    container_commands:
      ...    
      03wsgipass:
        command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
    

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

  • 1

    我也面临同样的问题 . 这对我有用:

    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"}
    

相关问题