Add links to enable Google Calendar API (#142377)

* Add links to enable Google Calendar API

* Update tests
This commit is contained in:
Kamil Breguła 2025-04-16 05:24:32 +02:00 committed by GitHub
parent a93121a88d
commit 1d845623a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -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")

View File

@ -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%]"

View File

@ -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"),
],
)