Skip to content

Commit f38a9cd

Browse files
AnaphylaxisDylan Issa
and
Dylan Issa
authored
Making token caching async-safe (#340)
Co-authored-by: Dylan Issa <dylan@fdylan.org>
1 parent 2c93646 commit f38a9cd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

custom_components/auth_header/__init__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from homeassistant.components.auth import DOMAIN as AUTH_DOMAIN
1212
from homeassistant.components.auth import indieauth
1313
from homeassistant.components.auth.login_flow import LoginFlowIndexView
14+
from homeassistant.components.http import StaticPathConfig
1415
from homeassistant.components.http.ban import log_invalid_auth
1516
from homeassistant.components.http.data_validator import RequestDataValidator
1617
from homeassistant.core import HomeAssistant
@@ -66,10 +67,15 @@ async def async_setup(hass: HomeAssistant, config):
6667
)
6768

6869
# Load script to store tokens in local storage, else we'll re-auth on every browser refresh.
69-
hass.http.register_static_path(
70-
"/auth_header/store-token.js",
71-
os.path.join(os.path.dirname(__file__), 'store-token.js'),
72-
)
70+
await hass.http.async_register_static_paths(
71+
[StaticPathConfig(
72+
"/auth_header/store-token.js",
73+
os.path.join(os.path.dirname(__file__), 'store-token.js'),
74+
True
75+
)
76+
]
77+
)
78+
7379
add_extra_js_url(hass, '/auth_header/store-token.js')
7480

7581
# Inject Auth-Header provider.

0 commit comments

Comments
 (0)