谷歌API日历手表不起作用,但通道已创建

2023-12-22

我尝试监听我的日历更改事件(谷歌应用程序/日历/v3/参考/事件/手表 https://developers.google.com/google-apps/calendar/v3/reference/events/watch).

我从 Google 控制台方面做了所有事情,域 - 好的,一切都经过验证,我成功创建了频道。我也成功得到了sync带有正确标题的消息(见下文)。来自文档:

同步消息

创建新的通知通道来监视资源后, Google Calendar API 发送一条同步消息来表明 通知正在开始。 X-Goog-Resource-State HTTP 标头 这些消息的值是同步的。由于网络时序问题, 即使在您收到同步消息之前也可以接收同步消息 观察方法响应。

这意味着notifications are starting

但是当我改变一些东西时[email protected] /cdn-cgi/l/email-protection帐户 -什么也没发生,没有请求发送到回调 : 'https://dev-api.mycompany/google-watch/'

这是我的工作代码:

var google = require('googleapis');
var googleAuth = require('google-auth-library');
var _ = require('underscore-node');


var uuid = require('node-uuid');

  // ......

                     var channel_id = uuid.v1();


                        _auth.credentials = {
                            access_token: _token.access_token,
                            token_type: _token.token_type,
                            refresh_token: _token.refresh_token,
                            expiry_date: _token.expiry_date
                        };

                        var data = {
                            auth: _auth,
                            calendarId: _token.provider_email, 
                            singleEvents: true,
                            orderBy: 'startTime',
                            resource: {
                                id: channel_id,
                                token: 'email='+_token.provider_email,
                                address: 'https://dev-api.mycompany/google-watch/',
                                type: 'web_hook',
                                params: {
                                    ttl: '36000'
                                }
                            }

                        };

                        calendar.events.watch(data, function (err, response) {
                            if (err) {
                                console.error('The API returned an error: ' + err);
                                 return;
                            }
                        });

当我开始上面提到的代码片段时,我得到响应:

{
  "kind": "api#channel",
  "id": "277fa000-d4b6-12e5-ab58-e7afaf85ea65",
  "resourceId": "C7vFL07CYfqaHy3vDss4qugWDfk",
  "resourceUri": "https://www.googleapis.com/calendar/v3/calendars/[email protected] /cdn-cgi/l/email-protection/events?orderBy=START_TIME&singleEvents=true&alt=json",
  "token": "[email protected] /cdn-cgi/l/email-protection",
  "expiration": "1455667451000"
}

And in 'https://dev-api.mycompany/google-watch/'我得到的网址sync关于文档的消息,例如(参见谷歌应用程序/日历/v3/推送 https://developers.google.com/google-apps/calendar/v3/push):

{
  "host": "dev-api.mycompany",
  "accept": "*/*",
  "accept-encoding": "gzip,deflate",
  "user-agent": "APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)",
  "x-goog-channel-expiration": "Tue, 16 Feb 2016 22:44:51 GMT",
  "x-goog-channel-id": "277fa000-d4b6-12e5-ab58-e7afaf85ea65",
  "x-goog-channel-token": "[email protected] /cdn-cgi/l/email-protection",
  "x-goog-message-number": "1",
  "x-goog-resource-id": "C7vFL07CYfqaHy3vDss4qugWDfk",
  "x-goog-resource-state": "sync",
  "x-goog-resource-uri": "https://www.googleapis.com/calendar/v3/calendars/[email protected] /cdn-cgi/l/email-protection/events?orderBy=START_TIME&singleEvents=true&alt=json",
  "x-forwarded-for": "56.102.7.132",
  "x-forwarded-port": "443",
  "x-forwarded-proto": "https",
  "content-length": "0",
  "connection": "keep-alive"
}

but not exists message

我错过了什么吗?

请帮忙,


我们已经使用推送通知几年了,并注意到在过去 24 小时内,我们没有收到数千个日历中的任何通知。

像您一样,我们可以创建/停止频道,但通常不会收到更改通知。

大约一个小时前,我们再次收到它们。请重试您的频道,因为这可能是 Google Push 方面的问题,但已解决。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

谷歌API日历手表不起作用,但通道已创建 的相关文章

随机推荐