[Django]-Django OAuth Toolkit setup issue

2đź‘Ť

Issue is with the “client id” and “client secret” generated during register application(http://django-oauth-toolkit.readthedocs.org/en/0.7.0/rest-framework/getting_started.html#step-3-register-an-application)

“client id” and “client secret” contains special characters which can’t be used with curl request in the mentioned way in documentation.

We can use it with the way suggested by Almalki as:

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/o/token/
👤Neo

1đź‘Ť

You can set client_id and client_secret as POST parameters:

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/o/token/
👤almalki

0đź‘Ť

I had the same problem as the OP and this was the only solution that worked for me:

curl -X POST -d 'grant_type=password&username=<username>&password=<password>' --user '<client_id>:<client_secret>' 'http://localhost:8000/o/token/'

I found this solution at Django OAuth Toolkit’s Github issue #167. There is a great explanation there.

👤j3py

Leave a comment