mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27: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 ConfigEntryAuthFailed from err
|
||||||
raise ConfigEntryNotReady 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)
|
coordinator = AutomowerDataUpdateCoordinator(hass, automower_api, entry)
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
available_devices = list(coordinator.data)
|
available_devices = list(coordinator.data)
|
||||||
@ -74,11 +79,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: AutomowerConfigEntry) ->
|
|||||||
"websocket_task",
|
"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)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -5,10 +5,7 @@ rules:
|
|||||||
unique-config-entry: done
|
unique-config-entry: done
|
||||||
config-flow-test-coverage: done
|
config-flow-test-coverage: done
|
||||||
runtime-data: done
|
runtime-data: done
|
||||||
test-before-setup:
|
test-before-setup: done
|
||||||
status: todo
|
|
||||||
comment: |
|
|
||||||
Raise ConfigEntryAuthFailed earlier, when "amc:api" is missing in the token scope.
|
|
||||||
appropriate-polling: done
|
appropriate-polling: done
|
||||||
entity-unique-id: done
|
entity-unique-id: done
|
||||||
has-entity-name: done
|
has-entity-name: done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user