Google 日历手表在初始同步通知后不会发送通知

问题描述 投票:0回答:1

我已在 Google 日历上设置了手表。


            WatchParamsModel watchParamsModel = new WatchParamsModel
            {
                TimeToLive = "2592000000", // 30 days is the max that google will allow
            };
            WatchRequest requestCode = new WatchRequest
            {
                ID = "abc_" + providerID + "_" + calendarID + "_" + DateTimeOffset.Now.ToUnixTimeSeconds(),
                Type = "web_hook",
                Address = address,
                Params = watchParamsModel,
                Token = "token",
            };

            string requestData = JsonConvert.SerializeObject(requestCode);

            string requestUrl = $"https://www.googleapis.com/calendar/v3/calendars/{calendarID}/events/watch?eventTypes=default";

            WatchResponse response = this.CreateAndExecuteHttpRequest<WatchResponse>(requestUrl, WebRequestMethods.Http.Post, requestData);
            return response;

我收到了包含所有预期信息的 200 回复

{  
"kind": "api#channel",  
"id": "watchid",  
"resourceId": "abc",  
"resourceUri": "https://www.googleapis.com/calendar/v3/calendars/{calURI}/events?alt=json&eventTypes=default",  
"token": "token",  
"expiration": "1711044580000" 
} 

和同步通知:

Method: POST, 
RequestUri: 'my endpoint', 
Version: 1.1, 
Content: System.Net.Http.StreamContent, 
Headers:  {    
Accept: */*  Accept-Encoding: gzip  
Host: my host  
User-Agent: APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)  
X-Forwarded-For: 123  
X-Forwarded-Proto: https  
X-Forwarded-Port: 443  
X-Amzn-Trace-Id: Root=abc  
CF-RAY: abc 
CF-Visitor: {"scheme":"https"}  
X-Goog-Channel-ID: channelId (same as above)
X-Goog-Channel-Expiration: Thu, 21 Mar 2024 22:47:00 GMT  
X-Goog-Resource-State: sync  
X-Goog-Message-Number: 1  
X-Goog-Resource-ID: resourceId (same as above)
X-Goog-Resource-URI: https://www.googleapis.com/calendar/v3/calendars/{calURI}/events?alt=json&eventTypes=default  
X-Goog-Channel-Token: token (same as above)  
CF-Connecting-IP: 74.125.212.171  
CDN-Loop: cloudflare  
True-Client-IP: 74.125.212.171  
CF-IPCountry: US
}

在端点内,要做的第一件事是记录任何传入的请求。但是,在检查日志时,当我在创建手表后在关联的谷歌日历中创建/编辑/删除事件时,我没有看到任何内容。我检查了我们的防火墙,没有发现来自谷歌的任何内容被阻止。我可以看到同步呼叫以及我们的 200 响应。当编辑事件时,我没有看到任何呼叫被防火墙或其他方式阻止。 为什么在初始同步呼叫后我没有收到任何对端点的呼叫?

google-calendar-api
1个回答
0
投票

删除 eventTypes=default 最有可能修复丢失的推送通知,正如 Alexey 在评论中分享的那样。 Google 在 2 月 7 日发出通知,表示应该支持 eventTypes=default,但截至 3 月 11 日我一直无法让它工作。删除参数将推送通知功能恢复到工作状态。

© www.soinside.com 2019 - 2024. All rights reserved.