Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleAPI NodeJS: calendar.events.watch gets error push.webhookUrlNotHttps or pushWebhookBadDomain

I have followed all the setups required in https://developers.google.com/google-apps/calendar/v3/push (I think) and I'm trying to register my callback URL to watch events, with this code:

calendar.events.watch({

    auth:jwtClient,
    resource: {
        id: "yourChannelId",
        type: 'web_hook',
        address: "https://api.mysite.com/notifications"
    },
    calendarId: "mycalendarId"
}, function(error, response) {
    if (error) {
        console.log(error);
        return;
    }
    console.log(response);

});

And I get the error message: 'No valid domain for WebHook callback: https://https://api.mysite.com', reason: 'pushWebhookBadDomain'. If I try to put the address as just "api.mysite.com/notifications" (as it seems that the https is getting duplicated), then I get the error message: 'WebHook callback must be HTTPS: api.mysite.com/notifications', reason: 'push.webhookUrlNotHttps'

Can anyone help me please? Thank you

like image 527
danielapsmaior Avatar asked Sep 26 '22 13:09

danielapsmaior


1 Answers

I got it to work. I hope it can help someone. Here is the way:

on Developers Console, the URL must be without the https but with the method included.

on Webmaster Tools, the URL must be with the https but just the cannonical domain.

My problem was that on Developers Console I added all possibilities (4 domains in total), but the service just uses the first one, which was wrong.

In the call, It was right, with https and method:

resource: {
    id: "yourChannelId",
    type: 'web_hook',
    address: "https://api.mysite.com/notifications"
}
like image 109
danielapsmaior Avatar answered Oct 11 '22 05:10

danielapsmaior