mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Check token scope earlier in Husqvarna Automower (#132289)
This commit is contained in:
parent
2977cf227e
commit
e55d8b2d2b
@ -62,6 +62,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: AutomowerConfigEntry) ->
|
||||
raise ConfigEntryAuthFailed from err
|
||||
raise ConfigEntryNotReady from err
|
||||
|
||||
if "amc:api" not in entry.data["token"]["scope"]:
|
||||
# We raise ConfigEntryAuthFailed here because the websocket can't be used
|
||||
# without the scope. So only polling would be possible.
|
||||
raise ConfigEntryAuthFailed
|
||||
|
||||
coordinator = AutomowerDataUpdateCoordinator(hass, automower_api, entry)
|
||||
await coordinator.async_config_entry_first_refresh()
|
||||
available_devices = list(coordinator.data)
|
||||
@ -74,11 +79,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: AutomowerConfigEntry) ->
|
||||
"websocket_task",
|
||||
)
|
||||
|
||||
if "amc:api" not in entry.data["token"]["scope"]:
|
||||
# We raise ConfigEntryAuthFailed here because the websocket can't be used
|
||||
# without the scope. So only polling would be possible.
|
||||
raise ConfigEntryAuthFailed
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
return True
|
||||
|
||||
|
@ -5,10 +5,7 @@ rules:
|
||||
unique-config-entry: done
|
||||
config-flow-test-coverage: done
|
||||
runtime-data: done
|
||||
test-before-setup:
|
||||
status: todo
|
||||
comment: |
|
||||
Raise ConfigEntryAuthFailed earlier, when "amc:api" is missing in the token scope.
|
||||
test-before-setup: done
|
||||
appropriate-polling: done
|
||||
entity-unique-id: done
|
||||
has-entity-name: done
|
||||
|
Loading…
x
Reference in New Issue
Block a user