From 4f886f78bcfaa22c513747400eed6f921a322cb6 Mon Sep 17 00:00:00 2001 From: eofs Date: Wed, 6 Feb 2013 15:33:52 +0200 Subject: [PATCH] Explain how to override ObtainAuthToken as it has limited support for parsers and renderers. --- docs/api-guide/authentication.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 59afc2b9f..f37493579 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -166,6 +166,17 @@ The `obtain_auth_token` view will return a JSON response when valid `username` a { 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' } +**Note:** View `obtain_auth_token` overrides default parser and renderer settings. It support outputting response in JSON format only. + +You can easily make your own version of `obtain_auth_token` by overriding `ObtainAuthToken`. Following example shows how to make `ObtainAuthToken` aware of API settings. + + from rest_framework.settings import api_settings + from rest_framework.authtoken.views import ObtainAuthToken + + class MyObtainAuthToken(ObtainAuthToken): + renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES + parser_classes = api_settings.DEFAULT_PARSER_CLASSES + ## SessionAuthentication This authentication scheme uses Django's default session backend for authentication. Session authentication is appropriate for AJAX clients that are running in the same session context as your website.