Home:ALL Converter>django-oauth-toolkit 'invalid client' error after deploy on AWS Elasticbeanstalk

django-oauth-toolkit 'invalid client' error after deploy on AWS Elasticbeanstalk

Ask Time:2018-02-20T05:42:51         Author:DKras

Json Formatter

I use django-oauth-toolkit with my django/django-rest-framework application. When I request an access token in dev mode on localhost, it works OK:

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

But if I request an access token from absolutely the same application deployed at AWS Elasticbeanstalk, I get 'invalid client' error:

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

Please advise me what to do to get rid of this error and normally request access tokens from django app deployed at AWS.

Author:DKras,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48874619/django-oauth-toolkit-invalid-client-error-after-deploy-on-aws-elasticbeanstalk
DKras :

After some research, I can now give the answer myself:\n\nI had to add one more command to my python.config in .ebextensions folder:\n\n...\ncontainer_commands:\n ... \n 03wsgipass:\n command: 'echo \"WSGIPassAuthorization On\" >> ../wsgi.conf'\n\n\nAfter that, AWS allows incoming requests to pass authorization, and I get the response without an error.",
2018-02-22T15:02:56
yy