Brad Erickson
2014-09-23 21:37:14 UTC
The ordering of the DEFAULT_AUTHENTICATION_CLASSES list matters. I'm using
DRF admin and the Chrome Postman app to test my API. When
SessionAuthentication is listed first and my browser is logged in the
Django admin, Token calls to the API fail with:
"detail": "CSRF Failed: CSRF token missing or incorrect."
According to the docs, if Session fails it should pass to the next
authentication system. DRF works as expected when setup like this:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
Session must be listed last. It should be mentioned in the docs or maybe
code needs changing? Should this be a github issue?
DRF admin and the Chrome Postman app to test my API. When
SessionAuthentication is listed first and my browser is logged in the
Django admin, Token calls to the API fail with:
"detail": "CSRF Failed: CSRF token missing or incorrect."
According to the docs, if Session fails it should pass to the next
authentication system. DRF works as expected when setup like this:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
Session must be listed last. It should be mentioned in the docs or maybe
code needs changing? Should this be a github issue?
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.