Skip to main content

Authentication

DRF provides pluggable authentication schemes for securing APIs.

Built-in Schemes

SchemeUse case
SessionAuthenticationBrowser-based clients
TokenAuthenticationSimple token-based auth
JWT (via packages)Stateless API auth

Configuration

REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}