Django REST Framework: using TokenAuthentication with browsable API

前端 未结 3 1189
我在风中等你
我在风中等你 2020-12-29 23:08

I\'m following the DRF docs to setup TokenAuthentication, and can\'t get it working with the browsable API. I believe I\'ve added the proper lines in settings.py

3条回答
  •  遥遥无期
    2020-12-29 23:50

    You can't use the browsable api with TokenAuthentication. You have to add SessionAuthtication to your settings (http://www.django-rest-framework.org/api-guide/authentication/#sessionauthentication):

    REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    

提交回复
热议问题