[Fixed]-How do i log in user using session based and basic auth in django rest framework?

1👍

You can exempt the CsrfToken follow this things.

authentication.py

from rest_framework.authentication import SessionAuthentication

class CsrfExemptSessionAuthentication(SessionAuthentication):

    def enforce_csrf(self, request):
        return True

Add this file in the settings.py

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'xxxxxx.authentication.CsrfExemptSessionAuthentication',
 )} 
👤Venkat

Leave a comment