diff --git a/falcon/exceptions.py b/falcon/exceptions.py index 76ba999..a603768 100644 --- a/falcon/exceptions.py +++ b/falcon/exceptions.py @@ -50,19 +50,9 @@ class HTTPUnauthorized(HTTPError): Use when authentication is required, and the provided credentials are not valid, or no credentials were provided in the first place. - Args: - title: Human-friendly error title - description: Human-friendly description of the error, along with a - helpful suggestion or two. - scheme: Authentication scheme to use as the value of the - WWW-Authenticate header in the response (default None). - - The remaining (optional) args are the same as for HTTPError. - - """ - def __init__(self, title, description, scheme=None, **kwargs): + def __init__(self, title, description, **kwargs): """Initialize Args: @@ -77,6 +67,8 @@ class HTTPUnauthorized(HTTPError): """ headers = kwargs.setdefault('headers', {}) + + scheme = kwargs.pop('scheme', None) if scheme is not None: headers['WWW-Authenticate'] = scheme diff --git a/falcon/tests/test_httperror.py b/falcon/tests/test_httperror.py index 1f72c31..b79776e 100644 --- a/falcon/tests/test_httperror.py +++ b/falcon/tests/test_httperror.py @@ -67,7 +67,7 @@ class UnauthorizedResource: def on_get(self, req, resp): raise falcon.HTTPUnauthorized('Authentication Required', 'Missing or invalid token header.', - 'Token') + scheme='Token; UUID') class UnauthorizedResourceSchemaless: @@ -259,7 +259,8 @@ class TestHTTPError(testing.TestBase): self.simulate_request('/401') self.assertEqual(self.srmock.status, falcon.HTTP_401) - self.assertIn(('WWW-Authenticate', 'Token'), self.srmock.headers) + self.assertIn(('WWW-Authenticate', 'Token; UUID'), + self.srmock.headers) def test_401_schemaless(self): self.api.add_route('/401', UnauthorizedResourceSchemaless())