Django REST Framework

API Authentication

Session and token auth basics

API Authentication

  • SessionAuthentication — same browser session as Django admin/UI
  • TokenAuthenticationAuthorization: Token <key> for scripts/mobile
REST_FRAMEWORK = {
    "DEFAULT_AUTHENTICATION_CLASSES": [
        "rest_framework.authentication.SessionAuthentication",
        "rest_framework.authentication.TokenAuthentication",
    ],
}
python manage.py drf_create_token ada