Search code examples
djangodjango-rest-frameworkdjango-rest-framework-simplejwt

Access data without token Django simple_jwt lib


I am using django simple_jwt library with DRF for a React project. Everything is working well except I cannot access any data (even simple GET requests) if no access token is provided. I didn't find a way to do it in the docs , is there some kind of decorator, setting to allow simple requests without an access token? Many thanks


Solution

  • If you want to access apis without token , make them public. By default all the api requests are required to be authenticated in your case currently.

    Sample:

    from rest_framework import permissions
    
    class ExampleApi(APIView):
        permission_classes = [permissions.AllowAny]
        authentication_classes = []