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
- [Django]-ListSerializer in Django Restful – When is it called?
- [Django]-Custom django-admin commands – AttributeError: 'Command' object has no attribute 'stdout'
- [Django]-Django – ListView – template for loop does not display any items
- [Django]-How does django locale work between views
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
- [Django]-Django and React: csrf cookie is not being set in request header
- [Django]-Django creates another media folder inside media folder
Source:stackexchange.com