谷歌API日历手表不起作用,但渠道创建 [英] google API calendar watch doesn't work but channel is created

查看:109
本文介绍了谷歌API日历手表不起作用,但渠道创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试收听我的日历更改事件( google-



我做了一切,从谷歌控制台端,域 - 好吧,一切都已验证,我成功了创建频道。另外,我成功获得了带有正确标题的 sync 消息(请参阅下文)。从文档:


同步信息



创建新的通知频道后一个资源,
Google Calendar API会发送一条同步消息来表明
通知正在启动。这些消息的X-Goog-Resource-State HTTP头
值是同步的。由于网络时间问题,甚至在您收到
watch方法响应之前,
都可能收到同步消息。


这意味着通知正在启动



然而,当我改变 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',
资源:{
id:channel_id,
token:'email ='+ _ token.provider_email,
address:'https://dev-api.mycompany/google-watch/' ,
类型:'web_hook',
params:{
ttl:'36000'
}
}

};

calendar.events.watch(数据,函数(err,response){
if(err){
console.error('API返回错误:'+ 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我得到同步留言关于文件,例如(请参阅 google-apps / calendar / v3 / push ):

  {
host:dev-api.mycompany,
accept:* / *,
accept-encoding:gzip,deflate,
user -agent:APIs-Google;(+ https://developers.google.com/webmasters/APIs-Go ),
x-goog-channel-expiration:2016年2月16日星期二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
}

但不是存在消息



我错过了什么吗?



请大家帮忙,

解决方案

我们一直使用Push Notifications几年,在过去的24小时里我们没有r您可以创建/停止某个频道,但不会收到任何通知,以便正常进行更改。


大约一小时前我们再次收到它们。请再次尝试您的频道,因为它可能是已解决事情的Google Push一方的小故障。


I try to listen on my calendar change events (google-apps/calendar/v3/reference/events/watch).

I did everything from Google console side, domains - OK, everything is verified and I succeeded to create channel. Also i succeeded to get sync message with right headers (see below). From docs:

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.

That mean that notifications are starting

However when I change something in snaggs@comp.com account - nothing happens, no request sends to callback : 'https://dev-api.mycompany/google-watch/'

This is my working code:

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;
                            }
                        });

When I start above mentioned snippets of code i get response:

{
  "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"
}

And in 'https://dev-api.mycompany/google-watch/' URL I get sync message regards to documents, like (See 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"
}

but not exists message

Do I miss something?

please help,

解决方案

We have been using Push Notifications for a few years and noticed that for the last 24 hours we did not receive any notifications across several thousand calendars.

Like you we can create/stop a channel but no notifications are received for changes as normal.

As of about an hour ago we are receiving them again. Please try your channel again as it may be a glitch on the Google Push side of things that has been resolved.

这篇关于谷歌API日历手表不起作用,但渠道创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆