google API 日历手表不工作但频道已创建
google API calendar watch doesn't work but channel is created
我试着听我的日历更改事件 (google-apps/calendar/v3/reference/events/watch)。
我从 Google 控制台端、域做了所有事情 - 好的,一切都已验证,我成功创建了频道。此外,我还成功地获得了 sync
右 headers 消息(见下文)。来自文档:
Sync message
After creating a new notification channel to watch a resource, the
Google Calendar API sends a sync message to indicate that
notifications are starting. The X-Goog-Resource-State HTTP header
value for these messages is sync. Because of network timing issues, it
is possible to receive the sync message even before you receive the
watch method response.
也就是说notifications are starting
然而,当我在 snaggs@comp.com
帐户中更改某些内容时 -
没有任何反应,没有请求发送到回调:'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/snaggs@comp.com/events?orderBy=START_TIME&singleEvents=true&alt=json",
"token": "email=snaggs@comp.com",
"expiration": "1455667451000"
}
并且在 'https://dev-api.mycompany/google-watch/'
URL 中,我收到 sync
关于文档的消息,例如(参见 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=snaggs@comp.com",
"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/snaggs@comp.com/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"
}
但不是 exists
消息
我错过了什么吗?
请帮忙,
几年来我们一直在使用推送通知,并注意到在过去的 24 小时内,我们在数千个日历中没有收到任何通知。
像您一样,我们可以 create/stop 频道,但不会像往常一样收到更改通知。
大约一个小时前,我们又收到了它们。请再次尝试您的频道,因为它可能是 Google 已解决问题的推送方面的故障。
我试着听我的日历更改事件 (google-apps/calendar/v3/reference/events/watch)。
我从 Google 控制台端、域做了所有事情 - 好的,一切都已验证,我成功创建了频道。此外,我还成功地获得了 sync
右 headers 消息(见下文)。来自文档:
Sync message
After creating a new notification channel to watch a resource, the Google Calendar API sends a sync message to indicate that notifications are starting. The X-Goog-Resource-State HTTP header value for these messages is sync. Because of network timing issues, it is possible to receive the sync message even before you receive the watch method response.
也就是说notifications are starting
然而,当我在 snaggs@comp.com
帐户中更改某些内容时 -
没有任何反应,没有请求发送到回调:'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/snaggs@comp.com/events?orderBy=START_TIME&singleEvents=true&alt=json",
"token": "email=snaggs@comp.com",
"expiration": "1455667451000"
}
并且在 'https://dev-api.mycompany/google-watch/'
URL 中,我收到 sync
关于文档的消息,例如(参见 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=snaggs@comp.com",
"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/snaggs@comp.com/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"
}
但不是 exists
消息
我错过了什么吗?
请帮忙,
几年来我们一直在使用推送通知,并注意到在过去的 24 小时内,我们在数千个日历中没有收到任何通知。
像您一样,我们可以 create/stop 频道,但不会像往常一样收到更改通知。
大约一个小时前,我们又收到了它们。请再次尝试您的频道,因为它可能是 Google 已解决问题的推送方面的故障。