mirror of
https://github.com/home-assistant/core.git
synced 2026-09-25 07:51:46 -05:00
Ask MCP authorization servers for a refresh token (#180604)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user