From 9591e711383a20cfa6254079c2e001cf84fc782e Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Wed, 24 Oct 2018 14:02:16 +0200 Subject: [PATCH] Update auth.py (#771) --- hassio/api/auth.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hassio/api/auth.py b/hassio/api/auth.py index bb03cea87..62a86308d 100644 --- a/hassio/api/auth.py +++ b/hassio/api/auth.py @@ -2,12 +2,13 @@ import logging from aiohttp import BasicAuth -from aiohttp.hdrs import CONTENT_TYPE, AUTHORIZATION +from aiohttp.web_exceptions import HTTPUnauthorized +from aiohttp.hdrs import CONTENT_TYPE, AUTHORIZATION, WWW_AUTHENTICATE from .utils import api_process from ..const import REQUEST_FROM, CONTENT_TYPE_JSON, CONTENT_TYPE_URL from ..coresys import CoreSysAttributes -from ..exceptions import APIError, APIForbidden +from ..exceptions import APIForbidden _LOGGER = logging.getLogger(__name__) @@ -55,4 +56,6 @@ class APIAuth(CoreSysAttributes): data = await request.post() return await self._process_dict(request, addon, data) - raise APIError("Auth method not detected!") + raise HTTPUnauthorized(headers={ + WWW_AUTHENTICATE: "Basic realm=\"Hass.io Authentication\"" + })