code: def post(self, request):
          
          serializer = AuthTokenSerializer(data=request.data)
  
          if serializer.is_valid():
              token, _ = ExpiringToken.objects.get_or_create(
                  user=serializer.validated_data['user']
              )
  
              if token.expired():
                  # If the token is expired, generate a new one.
                  token.delete()
                  token = ExpiringToken.objects.create(
                      user=serializer.validated_data['user']
                  )
  
              data = {'token': token.key}
              return Response(data)
  
          return Response(serializer.errors, status=HTTP_400_BAD_REQUEST)
docs: Respond to POSTed username/password with token.