tests/projects/common/headless/rest_framework/views.py
raw| 1 | from rest_framework.response import Response |
| 2 | from rest_framework.views import APIView |
| 3 | |
| 4 | from allauth.headless.contrib.rest_framework.authentication import ( |
| 5 | JWTTokenAuthentication, |
| 6 | ) |
| 7 | |
| 8 | |
| 9 | class ResourceView(APIView): |
| 10 | authentication_classes = [JWTTokenAuthentication] |
| 11 | |
| 12 | def get(self, request, *args, **kwargs): |
| 13 | data = {"resource": "ok"} |
| 14 | if "userinfo" in request.GET: |
| 15 | data["user_email"] = request.user.email |
| 16 | return Response(data) |