Add /me API endpoint

This commit is contained in:
Raphael Michel
2018-11-09 11:16:41 +01:00
parent 901953d988
commit 584ced87db
3 changed files with 54 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
from oauth2_provider.contrib.rest_framework import OAuth2Authentication
from rest_framework.authentication import SessionAuthentication
from rest_framework.response import Response
from rest_framework.views import APIView
class MeView(APIView):
authentication_classes = (SessionAuthentication, OAuth2Authentication)
def get(self, request, format=None):
return Response({
'email': request.user.email,
'fullname': request.user.fullname,
'locale': request.user.locale,
'timezone': request.user.timezone
})