Still request scopes in SmartThings (#139626)

Still request scopes
This commit is contained in:
Joost Lekkerkerker 2025-03-02 14:17:56 +01:00 committed by GitHub
parent 29f680f912
commit 3eadfcc01d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 5 deletions

View File

@ -11,7 +11,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.config_entry_oauth2_flow import AbstractOAuth2FlowHandler
from .const import CONF_LOCATION_ID, DOMAIN, OLD_DATA, SCOPES
from .const import CONF_LOCATION_ID, DOMAIN, OLD_DATA, REQUESTED_SCOPES, SCOPES
_LOGGER = logging.getLogger(__name__)
@ -30,7 +30,7 @@ class SmartThingsConfigFlow(AbstractOAuth2FlowHandler, domain=DOMAIN):
@property
def extra_authorize_data(self) -> dict[str, Any]:
"""Extra data that needs to be appended to the authorize url."""
return {"scope": " ".join(SCOPES)}
return {"scope": " ".join(REQUESTED_SCOPES)}
async def async_oauth_create_entry(self, data: dict[str, Any]) -> ConfigFlowResult:
"""Create an entry for SmartThings."""

View File

@ -17,6 +17,12 @@ SCOPES = [
"sse",
]
REQUESTED_SCOPES = [
*SCOPES,
"r:installedapps",
"w:installedapps",
]
CONF_APP_ID = "app_id"
CONF_CLOUDHOOK_URL = "cloudhook_url"
CONF_INSTALLED_APP_ID = "installed_app_id"

View File

@ -57,7 +57,8 @@ async def test_full_flow(
f"&state={state}"
"&scope=r:devices:*+w:devices:*+x:devices:*+r:hubs:*+"
"r:locations:*+w:locations:*+x:locations:*+r:scenes:*+"
"x:scenes:*+r:rules:*+w:rules:*+sse"
"x:scenes:*+r:rules:*+w:rules:*+sse+r:installedapps+"
"w:installedapps"
)
client = await hass_client_no_auth()
@ -128,7 +129,8 @@ async def test_not_enough_scopes(
f"&state={state}"
"&scope=r:devices:*+w:devices:*+x:devices:*+r:hubs:*+"
"r:locations:*+w:locations:*+x:locations:*+r:scenes:*+"
"x:scenes:*+r:rules:*+w:rules:*+sse"
"x:scenes:*+r:rules:*+w:rules:*+sse+r:installedapps+"
"w:installedapps"
)
client = await hass_client_no_auth()
@ -190,7 +192,8 @@ async def test_duplicate_entry(
f"&state={state}"
"&scope=r:devices:*+w:devices:*+x:devices:*+r:hubs:*+"
"r:locations:*+w:locations:*+x:locations:*+r:scenes:*+"
"x:scenes:*+r:rules:*+w:rules:*+sse"
"x:scenes:*+r:rules:*+w:rules:*+sse+r:installedapps+"
"w:installedapps"
)
client = await hass_client_no_auth()