OAuth is not handled by Django REST Framework, but there are a couple of pip modules that implement an OAuth client. The REST Framework documentation suggests one of the following modules:
pip install django-oauth-toolkit
INSTALLED_APPS = (
...
'oauth2_provider',
)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
)
}
urlpatterns = patterns(
...
url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
)
pip install djangorestframework-oauth django-oauth2-provider
INSTALLED_APPS = (
...
'provider',
'provider.oauth2',
)
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.OAuth2Authentication',
)
}
urlpatterns = patterns(
...
url(r'^oauth2/', include('provider.oauth2.urls', namespace='oauth2')),
)
Go to the admin panel and create a new Provider.Client
to have a client_id
and a client_secret
.