2👍
- Set
Authorization Grant Type
asResource owner password-based
- Put
WSGIPassAuthorization On
at same place asWSGIScriptAlias
1👍
You need to create a client through django admin UI and replace “MY_CLIENT_ID” with the ID.
- [Django]-Default parameters to actions with Django
- [Django]-Override Model.save() for FileField handled by Boto — Django
- [Django]-Django models – field dependency
- [Django]-Allowing URL access only to logged-in users
- [Django]-Django-extensions test_error_logging
1👍
Just to combine solutions. This is what worked for me. Follow through on the Getting Started guide. However, on creating the application, provide the following:
- Name: A name of your choosing
- Client Type: Public
- Authorization Grant Type: Resource owner password-based
Then the request should be:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=password&username=<username>&password=<password>&client_id=<client_id>" http://localhost:8000/o/token/
or, if JSON,
to settings.py add:
OAUTH2_PROVIDER = {
# expect request body Content Type application/json
'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore'
}
curl -X POST \
http://localhost:8000/o/token/ \
-H 'Content-Type: application/json' \
-d '{
"grant_type": "password",
"client_id": "<client_id>",
"username": "<username>",
"password": "<password>"
}'
- [Django]-Django urls dispatcher error (urls.E004) Ensure that urlpatterns is a list of url() instances
- [Django]-Django – models – how to describe a specific bidirectional relation between two models?
- [Django]-Testing Django view requiring user authentication with Factory Boy
- [Django]-How do I fix this error in Python Django involving request.user.is_authenticated() and bool object not callable?
0👍
You should use password grant type. The following curl command works with django-oauth-toolkit. I believe it should work with any other oauth provider as well.
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'grant_type=password&username=user&password=pass&client_id=client_id' 'http://localhost:8000/o/token/'
Please see the following link for more info: https://aaronparecki.com/articles/2012/07/29/1/oauth2-simplified#password
- [Django]-How to ensure at least one of the Fields is not blank in Serializer?
- [Django]-How to start Django up programmatically
Source:stackexchange.com