Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure Notion saves new refresh token upon startup #112676

Merged
merged 9 commits into from Mar 9, 2024
4 changes: 4 additions & 0 deletions homeassistant/components/notion/__init__.py
Expand Up @@ -180,6 +180,10 @@ def async_save_refresh_token(refresh_token: str) -> None:
# 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:
Expand Down