DRF 无法获取受限 URL 的数据
DRF Can't get data for restricted URLs
我正在使用 simple_JWT,我有一个需要登录用户的视图。
当我尝试发送请求时(通过邮递员、curl 等测试),我得到 'Authentication credentials were not provided'.
views.py :
class CurrencyDetailAPIView(generics.RetrieveAPIView):
serializer_class = CurrencyDetailSerializer
lookup_field = "slug"
permission_classes = [IsAuthenticated]
settings.py :
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}
获取最近的令牌并确保您在 header 中添加 Authorization
,值为 JWT {{your_token}}
不要跳过中间的 space。
我正在使用 simple_JWT,我有一个需要登录用户的视图。
当我尝试发送请求时(通过邮递员、curl 等测试),我得到 'Authentication credentials were not provided'.
views.py :
class CurrencyDetailAPIView(generics.RetrieveAPIView):
serializer_class = CurrencyDetailSerializer
lookup_field = "slug"
permission_classes = [IsAuthenticated]
settings.py :
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"rest_framework_simplejwt.authentication.JWTAuthentication",
],
}
获取最近的令牌并确保您在 header 中添加 Authorization
,值为 JWT {{your_token}}
不要跳过中间的 space。