認証資格情報の削除 --- django、elastic beanstalk、oauth 質問する

認証資格情報の削除 --- django、elastic beanstalk、oauth 質問する

django-rest-framework を使用して django に REST API を実装し、認証に oauth2 を使用しました。

以下を使用してテストしました:

curl -X POST -d "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=password&username=YOUR_USERNAME&password=YOUR_PASSWORD" http://localhost:8000/oauth2/access_token/

そして

curl -H "Authorization: Bearer <your-access-token>" http://localhost:8000/api/

ローカルホスト上で、ドキュメントと一致する成功した結果が得られました。

これを既存の AWS elastic beanstalk インスタンスにプッシュすると、次の結果が返されました。

{ "detail" : "Authentication credentials were not provided." }

ベストアンサー1

標準の場所にいくつかの追加構成を追加するというアイデアが気に入っています。.ebextensions ディレクトリに、次の内容を含む wsgi_custom.config ファイルを作成します。

files:
  "/etc/httpd/conf.d/wsgihacks.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      WSGIPassAuthorization On

ここに掲載されている通り:https://forums.aws.amazon.com/message.jspa?messageID=376244

おすすめ記事