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."
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.
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.