From 6a8116af1afe6b0b7a99da5f1adc35d65c61005c Mon Sep 17 00:00:00 2001 From: Leonardo Arroyo Date: Mon, 14 Nov 2016 18:32:43 -0200 Subject: [PATCH] Try to get WWW-Authenticate header from all authentication classes instead of only the first one (fixes #4680) --- rest_framework/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index a8710c7a0..8ffc27504 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -182,7 +182,11 @@ class APIView(View): """ authenticators = self.get_authenticators() if authenticators: - return authenticators[0].authenticate_header(request) + for authenticator in authenticators: + authenticate_header = authenticator.authenticate_header(request) + if authenticate_header: + return authenticate_header + return None def get_parser_context(self, http_request): """