试用 Google Analytics 的 MCP 服务器。从
GitHub 安装,并参阅
公告了解详情。
WebhookNotification
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
配置一个长时间运行的操作资源,以便在资源更新时从 Google Analytics Data API 向您的 webhook 服务器发送 webhook 通知。
通知配置包含私密值,并且仅对您的 GCP 项目可见。不同的 GCP 项目可以将不同的 webhook 通知附加到同一长时间运行的操作资源。
JSON 表示法 |
{
"uri": string,
"channelToken": string
} |
字段 |
uri |
string
可选。将接收 webhook 通知的网址。当长时间运行的操作资源状态发生变化时,此地址将会收到 POST 请求。POST 请求将在正文中包含长时间运行的操作资源的 JSON 版本,以及 sentTimestamp 字段。发送时间戳将指定自请求发送之时起的 Unix 微秒数;这样,您就可以识别重放的通知。 示例 URI 为 https://us-central1-example-project-id.cloudfunctions.net/example-function-1 。 URI 必须使用 HTTPS,并指向网络服务器上具有有效 SSL 证书的网站。URI 的字符串长度不得超过 128 个字符,并且只能使用 RFC 1738 中的许可名单字符。 当您的网络钩子服务器收到通知时,应在 5 秒内回复 HTTP 响应状态代码 200。 必须提供 URI 才能使用网络钩子通知。 发送到此 webhook 服务器的请求将包含用于对服务账号 google-analytics-audience-export@system.gserviceaccount.com 进行身份验证的 ID 令牌。如需详细了解 ID 令牌,请参阅 https://cloud.google.com/docs/authentication/token-types#id。对于 Google Cloud Functions,您可以通过此方法将函数配置为需要身份验证。在 Cloud IAM 中,您需要向服务账号授予 Cloud Run Invoker (roles/run.invoker ) 和 Cloud Functions Invoker (roles/cloudfunctions.invoker ) 角色的权限,以便该 webhook 发布请求能够通过 Google Cloud Functions 身份验证。此 API 可以向任意 URI 发送 webhook 通知;对于 Google Cloud Functions 以外的 webhook 服务器,如果不需要授权 Bearer 标头中的此 ID 令牌,则应忽略该令牌。
|
channelToken |
string
可选。渠道令牌是一个任意字符串值,字符串长度不得超过 64 个字符。借助渠道令牌,您可以验证 webhook 通知的来源。这可防止邮件被仿冒。渠道令牌将在 webhook POST 请求的 X-Goog-Channel-Token HTTP 标头中指定。 您无需渠道令牌即可使用网络钩子通知。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eWebhook notifications can be configured for long-running operations in the Google Analytics Data API to send updates to your server.\u003c/p\u003e\n"],["\u003cp\u003eThese notifications are project-specific and include a JSON payload with operation details and a timestamp.\u003c/p\u003e\n"],["\u003cp\u003eThe webhook configuration requires a URI using HTTPS with a valid SSL certificate, and optionally, a channel token for verification.\u003c/p\u003e\n"],["\u003cp\u003eWhen receiving a notification, your server should respond with an HTTP 200 status code within 5 seconds.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication for Google Cloud Functions is provided through an ID token representing the service account \u003ccode\u003egoogle-analytics-audience-export@system.gserviceaccount.com\u003c/code\u003e, while other webhook servers can ignore this token.\u003c/p\u003e\n"]]],["This document outlines the configuration for webhook notifications from the Google Analytics Data API. You can set up a webhook server (`uri`) to receive POST requests containing long-running operation resource updates in JSON format, along with a `sentTimestamp`. The `uri` must be HTTPS with a valid SSL certificate and is required for webhook notifications. Optionally, use a `channelToken` for source verification, which is included in the `X-Goog-Channel-Token` header. Notifications will include an ID token for authentication.\n"],null,["# WebhookNotification\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nConfigures a long-running operation resource to send a webhook notification from the Google Analytics Data API to your webhook server when the resource updates.\n\nNotification configurations contain private values \\& are only visible to your GCP project. Different GCP projects may attach different webhook notifications to the same long-running operation resource.\n\n| JSON representation |\n|---------------------------------------------------|\n| ``` { \"uri\": string, \"channelToken\": string } ``` |\n\n| Fields ||\n|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `uri` | `string` Optional. The web address that will receive the webhook notification. This address will receive POST requests as the state of the long running operation resource changes. The POST request will contain both a JSON version of the long running operation resource in the body and a `sentTimestamp` field. The sent timestamp will specify the unix microseconds since the epoch that the request was sent; this lets you identify replayed notifications. An example URI is `https://us-central1-example-project-id.cloudfunctions.net/example-function-1`. The URI must use HTTPS and point to a site with a valid SSL certificate on the web server. The URI must have a maximum string length of 128 characters \\& use only the allowlisted characters from [RFC 1738](https://www.rfc-editor.org/rfc/rfc1738). When your webhook server receives a notification, it is expected to reply with an HTTP response status code of 200 within 5 seconds. A URI is required to use webhook notifications. Requests to this webhook server will contain an ID token authenticating the service account `google-analytics-audience-export@system.gserviceaccount.com`. To learn more about ID tokens, see \u003chttps://cloud.google.com/docs/authentication/token-types#id\u003e. For Google Cloud Functions, this lets you configure your function to require authentication. In Cloud IAM, you will need to grant the service account permissions to the Cloud Run Invoker (`roles/run.invoker`) \\& Cloud Functions Invoker (`roles/cloudfunctions.invoker`) roles for the webhook post request to pass Google Cloud Functions authentication. This API can send webhook notifications to arbitrary URIs; for webhook servers other than Google Cloud Functions, this ID token in the authorization bearer header should be ignored if it is not needed. |\n| `channel``Token` | `string` Optional. The channel token is an arbitrary string value and must have a maximum string length of 64 characters. Channel tokens allow you to verify the source of a webhook notification. This guards against the message being spoofed. The channel token will be specified in the `X-Goog-Channel-Token` HTTP header of the webhook POST request. A channel token is not required to use webhook notifications. |"]]