Ask MCP authorization servers for a refresh token (#180604)

This commit is contained in:
Franck Nijhof
2026-08-29 13:17:04 +02:00
committed by GitHub
parent 193aa5113a
commit 6b0e63568a
2 changed files with 8 additions and 2 deletions
+5 -1
View File
@@ -315,7 +315,11 @@ class ModelContextProtocolConfigFlow(AbstractOAuth2FlowHandler, domain=DOMAIN):
@override
def extra_authorize_data(self) -> dict:
"""Extra data that needs to be appended to the authorize url."""
data = {}
data = {
# Add params to ensure we get back a refresh token
"access_type": "offline",
"prompt": "consent",
}
if self.data and (scopes := self.data[CONF_SCOPE]) is not None:
data[CONF_SCOPE] = " ".join(scopes)
data.update(super().extra_authorize_data)
+3 -1
View File
@@ -341,7 +341,9 @@ async def perform_oauth_flow(
assert result["url"] == (
f"{authorize_url}?response_type=code&client_id={CLIENT_ID}"
f"&redirect_uri={OAUTH_CALLBACK_URL}"
f"&state={state}{scope_param}"
f"&state={state}"
# Asked for so the server hands back a refresh token
f"&access_type=offline&prompt=consent{scope_param}"
)
client = await hass_client_no_auth()