赞
踩
- REST_FRAMEWORK = {
- 'DEFAULT_AUTHENTICATION_CLASSES': (
- 'rest_framework.authentication.BasicAuthentication', # 基本认证
- 'rest_framework.authentication.SessionAuthentication', # session认证
- )
- }
- from rest_framework.authentication import SessionAuthentication, BasicAuthentication
- class BookInfoViewSet(mixins.ListModelMixin,mixins.RetrieveModelMixin,GenericViewSet):
- """使用GenericViewSet实现返回列表和单一值"""
- authentication_classes = (SessionAuthentication, BasicAuthentication)
认证失败会有两种可能的返回值:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。