Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am very new to google apis can i am trying to implement google calendar webhooks where i am trying to get the notification if there is any event added to the calendar....

I have added my domain to Search Console verified teh domain too...

I have added my domain in the Domain verification section too..

I am using this below link to test :

https://developers.google.com/google-apps/calendar/v3/reference/events/watch

Now i am trying to validate then it is throwing an exception as : Unauthorized WebHook callback channel: https://www.test.com/

Can you please let me know what am i missing

It would be of great help if you can provide me some working code...

What I have tried:

I have tried sending as :

"address": "https://www.test.com/notification.aspx",
"id": "01234567-89ab-cdef-0123456789ab",
"type": "web_hook"

Return i am getting as :

{
"error": {
"errors": [
{
"domain": "global",
"reason": "push.webhookUrlUnauthorized",
"message": "Unauthorized WebHook callback channel: https://www.test.com/notification.aspx"
}
],
"code": 401,
"message": "Unauthorized WebHook callback channel: https://www.test.com/notification.aspx"
}
}



I have also tried :

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/calendar/v3/calendars/xxx@gmail.com/events/watch");
          request.Method = "POST";


          request.ContentType = "application/json";
          string postData = "type=web_hook&id=01234567-89ab-cdef-0123456789ab&address=https://www.xxx.com/notification.aspx";
          byte[] bytes = Encoding.UTF8.GetBytes(postData);
          request.ContentLength = bytes.Length;

          Stream requestStream = request.GetRequestStream();
          requestStream.Write(bytes, 0, bytes.Length);

          WebResponse response = request.GetResponse();
          Stream stream = response.GetResponseStream();
          StreamReader reader = new StreamReader(stream);

          var result = reader.ReadToEnd();
          stream.Dispose();
          reader.Dispose();
Posted
Updated 5-Mar-17 23:46pm
v3
Comments
F-ES Sitecore 6-Mar-17 5:47am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900