From 1d845623a8efc09d2222205dc0acb803728ced8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= Date: Wed, 16 Apr 2025 05:24:32 +0200 Subject: [PATCH] Add links to enable Google Calendar API (#142377) * Add links to enable Google Calendar API * Update tests --- homeassistant/components/google/config_flow.py | 7 ++++++- homeassistant/components/google/strings.json | 2 +- tests/components/google/test_config_flow.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/google/config_flow.py b/homeassistant/components/google/config_flow.py index 8ae09b58957..add75f5e95b 100644 --- a/homeassistant/components/google/config_flow.py +++ b/homeassistant/components/google/config_flow.py @@ -197,7 +197,12 @@ class OAuth2FlowHandler( "Error reading primary calendar, make sure Google Calendar API is enabled: %s", err, ) - return self.async_abort(reason="api_disabled") + return self.async_abort( + reason="calendar_api_disabled", + description_placeholders={ + "calendar_api_url": "https://console.cloud.google.com/apis/library/calendar-json.googleapis.com" + }, + ) except ApiException as err: _LOGGER.error("Error reading primary calendar: %s", err) return self.async_abort(reason="cannot_connect") diff --git a/homeassistant/components/google/strings.json b/homeassistant/components/google/strings.json index 5776fd0480b..4f3e27af27e 100644 --- a/homeassistant/components/google/strings.json +++ b/homeassistant/components/google/strings.json @@ -28,7 +28,7 @@ "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]", "timeout_connect": "[%key:common::config_flow::error::timeout_connect%]", "code_expired": "Authentication code expired or credential setup is invalid, please try again.", - "api_disabled": "You must enable the Google Calendar API in the Google Cloud Console" + "calendar_api_disabled": "You must [enable the Google Calendar API]({calendar_api_url}) in the Google Cloud Console" }, "create_entry": { "default": "[%key:common::config_flow::create_entry::authenticated%]" diff --git a/tests/components/google/test_config_flow.py b/tests/components/google/test_config_flow.py index de882a6f791..e5f4e512579 100644 --- a/tests/components/google/test_config_flow.py +++ b/tests/components/google/test_config_flow.py @@ -570,7 +570,7 @@ async def test_reauth_flow( ("primary_calendar_error", "primary_calendar_status", "reason"), [ (ClientError(), None, "cannot_connect"), - (None, HTTPStatus.FORBIDDEN, "api_disabled"), + (None, HTTPStatus.FORBIDDEN, "calendar_api_disabled"), (None, HTTPStatus.SERVICE_UNAVAILABLE, "cannot_connect"), ], )