Make sure Notion saves new refresh token upon startup (#112676)
* Make sure Notion saves new refresh token upon startup * Code review * Typing * Smoother syntax * Fix tests * Fix tests for real
This commit is contained in:
parent
5b2a24b1bb
commit
3405bda835
3 changed files with 20 additions and 7 deletions
|
@ -181,6 +181,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
# Create a callback to save the refresh token when it changes:
|
||||
entry.async_on_unload(client.add_refresh_token_callback(async_save_refresh_token))
|
||||
|
||||
# Save the client's refresh token if it's different than what we already have:
|
||||
if (token := client.refresh_token) and token != entry.data[CONF_REFRESH_TOKEN]:
|
||||
async_save_refresh_token(token)
|
||||
|
||||
hass.config_entries.async_update_entry(entry, **entry_updates)
|
||||
|
||||
async def async_update() -> NotionData:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue