我已将 django-rest-framework 与 django-oauth-toolkit 集成。它给了我{"detail": "Authentication credentials were not provided."}
未经身份验证的 API。
这是我的settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
)
}
视图.py
from rest_framework.views import APIView
from rest_framework.response import Response
class SignUpView(APIView):
"""
Signup for the user.
"""
def get(self, request):
return Response({'result': True, 'message': 'User registered successfully.'})
网址.py
from django.urls import path
from myapp.views import SignUpView
urlpatterns = [
path('signup/', SignUpView.as_view()),
]