Reputation: 1706
Heres my code:
var google = googleapis;
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2('xxxxxx', 'xxxxxxx', 'https://bt-feedback.meteor.com/oauth2');
oauth2Client.setCredentials({
access_token: 'xxxxxxxx',
refresh_token: 'xxxxxxxx'
});
google.options({ auth: oauth2Client }); // set auth as a global default
var calendar = google.calendar('v3');
calendar.events.watch({
calendarId: 'xxxxxxxxxxx'
},
{
id: 'xxx-xx-xx-xx-xxxxxxxxxx',
address: 'https://bt-feedback.meteor.com/notifications',
type: 'web_hook'
}, function(err, res) {
console.log("err, res:", err, res);
});
Here's the error I keep getting:
W20150128-16:12:24.574(-7)? (STDERR) { errors:
W20150128-16:12:24.576(-7)? (STDERR) [ { domain: 'global',
W20150128-16:12:24.576(-7)? (STDERR) reason: 'required',
W20150128-16:12:24.576(-7)? (STDERR) message: 'entity.resource' } ],
W20150128-16:12:24.576(-7)? (STDERR) code: 400,
W20150128-16:12:24.576(-7)? (STDERR) message: 'entity.resource' }
Any idea whats up!? I checked out a bunch of diff questions but none of them seem to help any.
Upvotes: 2
Views: 1033
Reputation: 21
I had the same problem. I didn't have time to figure out why the googleapis module isn't working on this point, but I got a direct API request working.
request.post('https://www.googleapis.com/calendar/v3/calendars/[calendarName]/events/watch',{
headers:{
Authorization:'Bearer '+oauth2Client.credentials.access_token
,'content-type':'application/json'
}
,json:true
,body:{
id:[channelId]
,type:'web_hook'
,address:[callbackUrl]
}},callback);
Upvotes: 2