Permissions with IsAuthenticated
A snippet showing how to use IsAuthenticated permission class.
# views.py
from rest_framework.permissions import IsAuthenticated
from rest_framework.views import APIView
from rest_framework.response import Response
class PrivateProfile(APIView):
permission_classes = [IsAuthenticated]
def get(self, request):
return Response({"email": request.user.email})
Explanation:
- Only authenticated requests (via configured auth classes) can access the endpoint.
- Category Django REST Framework (DRF)
- Total Views 654
- Last Modified 23 June, 2026
- Tags #drf #permissions #authentication #api
Previous snippet
JWT Authentication Example
Next snippet