don't send WWW-Authenticate: Basic for AJAX, and properly detect 401

This commit is contained in:
Ryan Petrello
2018-06-25 16:41:29 -04:00
parent 2ca4c08567
commit 7880f83d97
3 changed files with 7 additions and 2 deletions

View File

@@ -233,6 +233,8 @@ class APIView(views.APIView):
use the request header as an indication for which authentication method
was attempted.
"""
if request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest':
return 'Bearer realm=api'
for authenticator in self.get_authenticators():
try:
resp_hdr = authenticator.authenticate_header(request)