2
votes

I have created a project in django rest framework and installed django auth provider and created a application and generated the client id and client secret and when i am testing the application using curl request

curl -X POST -d "grant_type=password&username=&password=" -u":" http://localhost:8000/o/token/

I tested by giving my username,password, client_id and client_request showing error like

{"error": "invalid_client"}

settings.py

 OAUTH2_PROVIDER = {
    # this is the list of available scopes
    'SCOPES': {'read': 'Read scope', 
               'write': 'Write scope', 
               'groups': 'Access to your groups'}
}

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
        'oauth2_provider.ext.rest_framework.OAuth2Authentication',
    )
}
1

1 Answers

0
votes

You're using 'o'i n your url so your urs.py has to contain

url(r'^o/(?P<token>[\w-]+)/$', YourView.as_view()),

Looks like your url is not known to urls.py

For example having

url(r'^users/(?P<pk>[0-9]+)/$', views.UserDetail.as_view()),)

would make

curl http://127.0.0.1:8000/users/1/

render normally.