所以我按照本教程的指南在我的Django Web服务器上实现了一个令牌认证系统: http://cheng.logdown.com/posts/2015/10/27/how-to-use-django-rest-frameworks-token-based-authentication 但是每个api调用都需要一个令牌,否则我会收到未经授权的错误。我需要免费拨打一些api电话,这意味着任何人,不仅是注册用户(当然还有令牌)都可以拨打电话。这是怎么做到的?
答案 0 :(得分:0)
查看该文章,您可能已在设置的全局基础上设置了身份验证方案。
如果您只想对几个选择视图进行身份验证,则不能全局设置它,而是按照此处说明的每个视图设置:
http://www.django-rest-framework.org/api-guide/authentication/#setting-the-authentication-scheme
class ExampleView(APIView):
authentication_classes = (SessionAuthentication, BasicAuthentication)
permission_classes = (IsAuthenticated,)