sei-ec-remote / project-4-issues

Open an issue to receive help on project 4
0 stars 0 forks source link

Cannot run index route b/c of a credential issue #16

Closed davidnierman closed 2 years ago

davidnierman commented 2 years ago

What stack are you using?

(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)

DR

What's the problem you're trying to solve?

Cannot display locations when running /index/ route in postman b/c there is some authentication error

Post any code you think might be relevant (one fenced block per file)

from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
# from rest_framework.authtoken.models import TokenAuthentication
from rest_framework import generics

from ..models.location import Location
from ..serializers import LocationSerializer

# Views
class Locations(generics.ListCreateAPIView):
    # authentication_classes = [TokenAuthentication]
    # permission_classes=(IsAuthenticated)
    serializer_class = LocationSerializer
    def get(self):
        """Index request"""
        locations = Location.objects.all()
        data = LocationSerializer(locations, many=True).data
        return Response({ 'locations': data })

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

{ "detail": "Authentication credentials were not provided." }

What is your best guess as to the source of the problem?

the view/route does not know that it can receive a token. so even though i am sending the token it is not accepting it and throwing the error above

What things have you already tried to solve the problem?

I have tried commenting out code that I thought was requiring authentication, but that did not work..

I have tried and I am still continuing to read the documentation here: Token Auth

Paste a link to your repository here composting-mgmt-systems-ap

DoireannJane commented 2 years ago

https://github.com/sei-ec-remote/project-4-issues/issues/8 <-- is this this issue you're having?

davidnierman commented 2 years ago

https://stackoverflow.com/questions/53649252/django-rest-framework-basepermissionmetaclass-object-is-not-iterable

davidnierman commented 2 years ago

I was missing a comma see stack overflow comment above