mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
parent
3f70437888
commit
667a453a35
@ -166,12 +166,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
implementation = await async_get_config_entry_implementation(hass, entry)
|
implementation = await async_get_config_entry_implementation(hass, entry)
|
||||||
oauth_session = OAuth2Session(hass, entry, implementation)
|
oauth_session = OAuth2Session(hass, entry, implementation)
|
||||||
|
|
||||||
|
refresh_lock = asyncio.Lock()
|
||||||
|
|
||||||
async def _refresh_token() -> str:
|
async def _refresh_token() -> str:
|
||||||
await oauth_session.async_ensure_token_valid()
|
async with refresh_lock:
|
||||||
token = oauth_session.token[CONF_ACCESS_TOKEN]
|
await oauth_session.async_ensure_token_valid()
|
||||||
if TYPE_CHECKING:
|
token = oauth_session.token[CONF_ACCESS_TOKEN]
|
||||||
assert isinstance(token, str)
|
if TYPE_CHECKING:
|
||||||
return token
|
assert isinstance(token, str)
|
||||||
|
return token
|
||||||
|
|
||||||
client.refresh_token_function = _refresh_token
|
client.refresh_token_function = _refresh_token
|
||||||
withings_data = WithingsData(
|
withings_data = WithingsData(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user