[Answered ]-Making use of the token generated upon log in

1๐Ÿ‘

โœ…

If the user is authenticated, you can find the logged in user who is using that token, tokens are usually passed with the header with each request.

You can use a serializer for user details:

@api_view(['GET'])
def current_user(request):
    serializer = UserSerializer(request.user)
    return Response(serializer.data)

or without serializer:

@api_view(['GET'])
def current_user(request):
    user = request.user
    return Response({
        'username': user.username,
        'email': user.email
    })

Leave a comment