Django Rest Frameworks: All endpoints require authentication

I’m trying to set up Auth0 for an existing Django REST framework API. I’ve followed the Django API: Authorization tutorial, except for the part about public and private endpoints, because they don’t fit my use case. (I need all endpoints to be publicly accessible. Authentication should only be required for one endpoint with the POST method.)

My problem now is that I’m getting 401 Unauthorized on all requests, even GET /, with "detail": "Authentication credentials were not provided."

Any idea what has I’ve done wrong?

I was able to make the example work. However, it was quite confusing as there are some differences between the example and the tutorial. (For example, the example uses a .env file, while the tutorial does not.)

I think I’ll try to make my app work by using the code from the example rather than from the tutorial.

Thanks a lot @yhoiseth for providing that feedback! I’ll make sure to relay that to appropriate team!

@konrad.sopala Thanks :slight_smile:

I’ve made some more progress: The reason why my API was suddenly blocking all unauthenticated requests is the setting for DEFAULT_PERMISSION_CLASSES. By default, it’s AllowAny, but in the tutorial and example, it’s set to IsAuthenticated.

Once I removed it, my API started accepting requests again.

Perfect! Glad to hear that!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.