Browse Source

Enable token authorization for API calls

pull/317/head
Clemens Wolff 5 years ago
parent
commit
45ac8d2eb3
2 changed files with 7 additions and 0 deletions
  1. 2
      app/api/urls.py
  2. 5
      app/app/settings.py

2
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'),

5
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',),

Loading…
Cancel
Save