'Djoser user_list setting AllowAny not working

I have created login Api using Djoser for authentication. I want to get the list of users using a GET api call (/api/auth/users/ endpoint) but I get an error saying

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

I have added djoser settings in setting.py file like this

DJOSER={
    'user': ['djoser.permissions.AllowAny'],
    'user_list': ['djoser.permissions.AllowAny'],
    'SERIALIZERS':{
        'user_create':'restapi_subserv.serializers.UserCreateSerializer',
        'user':'restapi_subserv.serializers.UserCreateSerializer',

    }
}

But Still, I get the error. Am I missing something?

Please let me know if you need any more details.



Solution 1:[1]

You have to specify that you're trying to override the default permissions just like you did with the serializers:

DJOSER = {
    'PERMISSIONS': {
        'user': ['djoser.permissions.AllowAny'],
        'user_list': ['djoser.permissions.AllowAny'],
    },
    'SERIALIZERS': {
        'user_create': 'restapi_subserv.serializers.UserCreateSerializer',
        'user': 'restapi_subserv.serializers.UserCreateSerializer',

    }
}

The documentation doesn't do a very good job at specifying this.

Solution 2:[2]

set hide_users to false

DJOSER = {
    'HIDE_USERS': False,
    'PERMISSIONS': {

    'user': ['rest_framework.permissions.AllowAny'],
    'user_list': ['rest_framework.permissions.AllowAny'],

    },

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Badredine Kheddaoui
Solution 2 Thamer Sekhri