diff --git a/app/api/urls.py b/app/api/urls.py index b06b1458..2ee6b1fc 100644 --- a/app/api/urls.py +++ b/app/api/urls.py @@ -1,4 +1,5 @@ from django.urls import path +from rest_framework.authtoken.views import obtain_auth_token from rest_framework.urlpatterns import format_suffix_patterns from .views import Me, Features @@ -11,6 +12,7 @@ from .views import StatisticsAPI urlpatterns = [ + path('auth-token', obtain_auth_token), path('me', Me.as_view(), name='me'), path('features', Features.as_view(), name='features'), path('cloud-upload', CloudUploadAPI.as_view(), name='cloud_uploader'), diff --git a/app/app/settings.py b/app/app/settings.py index 63107917..e77b402e 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -55,6 +55,7 @@ INSTALLED_APPS = [ 'api.apps.ApiConfig', 'widget_tweaks', 'rest_framework', + 'rest_framework.authtoken', 'django_filters', 'social_django', 'polymorphic', @@ -210,6 +211,10 @@ REST_FRAMEWORK = { 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', 'rest_framework.permissions.IsAuthenticated', ], + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.SessionAuthentication', + 'rest_framework.authentication.TokenAuthentication', + ), 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 5, 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',),