Asked  10 Months ago    Answers:  5   Viewed   186 times

I want to listen programmatically when an event I created on the Google calendar is updated (like when someone accept/reject an invite) and I want to receive the relevant info regarding the event (type, confirmed/declined attendees, etc). I've tried using zapier and so far it does the job. Is there a native way to do that using Google API? I've also tried using Google calendar push notifications but the data I've received from the webhook isn't sufficient for my use case. Thanks!

 Answers

2

You should be able to do this with a small Google Apps Script.

Their documentation explains the process of listening for a calendar change event. Then, you'll need to perform an incremental sync with the Calendar Sync API and handle the specifics of the event based on how you want.

Note that more simply, a webhook may suffice for your use case.

Friday, August 27, 2021
 
rypskar
 
3

You can only impersonate users on a google apps domain where you have the necessary permission for (search for 'domain wide delegation'). You've got that covered.

Once you're authorized for impersonation you have to recreate a fresh Google Client for each user you impersonate. You'll only receive an access_token you can use for this very user. If you just change the email address once you're authorized it will not work.

Saturday, May 29, 2021
 
4

I think you're way overthinking this one. If you just need access to events on a public calendar, then there's a way to do this without invoking the Google Calendar API and all of the attached complexity. Every public Google Calendar has an iCal feed that can be viewed at a specific URL, usually in the form of:

http://www.google.com/calendar/ical/{OWNER}/public/basic.ics

where {OWNER} is the URL-encoded email address of the owner of the calendar.

You can find the specific URL by viewing the calendar settings and scrolling to the bottom of the Calendar Details tab.

Sunday, August 15, 2021
5

Answer:

You need to use the conferenceData.createRequest parameter of the Events resource when creating a Calendar.Events: insert request to add a Meet link to a Calendar Event.

More Information:

As per the documention for Events: insert and the Event resource reperesentation:

conferenceDataVersion: integer

Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0. Acceptable values are 0 to 1, inclusive.


conferenceData.createRequest: nested object

A request to generate a new conference and attach it to the event. The data is generated asynchronously. To see whether the data is present check the status field.

Either conferenceSolution and at least one entryPoint, or createRequest is required.


conferenceData.createRequest.conferenceSolutionKey.type: string

The conference solution type.

If a client encounters an unfamiliar or empty type, it should still be able to display the entry points. However, it should disallow modifications.

The possible values are:

  • "eventHangout" for Hangouts for consumers (http://hangouts.google.com)
  • "eventNamedHangout" for classic Hangouts for G Suite users (http://hangouts.google.com)
  • "hangoutsMeet" for Google Meet (http://meet.google.com)
  • "addOn" for 3P conference providers

conferenceData.createRequest.requestId: string

The client-generated unique ID for this request. Clients should regenerate this ID for every new request. If an ID provided is the same as for the previous request, the request is ignored.

With this information we can generate a Calendar Event creation request with a Meet link as the conference solution.

Example Request:

gapi.client.calendar.events.insert({
  "calendarId": "primary",
  "conferenceDataVersion": 1,
  "resource": {
    "end": {
      "date": "2020-10-24"
    },
    "start": {
      "date": "2020-10-23"
    },
    "conferenceData": {
      "createRequest": {
        "conferenceSolutionKey": {
          "type": "hangoutsMeet"
        },
        "requestId": "some-random-string"
      }
    },
    "summary": "titles are cool"
  }
});

NB: In order for a Meet link to be generated, you must set conferenceData.createRequest.requestId to any random string. For each new meet link you wish to create, you must use a different string in the request.

I hope this is helpful to you!

References:

  • Events: insert | Calendar API | Google Developers
  • Events | Calendar API | Google Developers
Thursday, August 19, 2021
 
1

events[j] is being rebound on each iteration of the for loop. Try using an anonymous function to bind to the correct event:

var request;
for(var j = 0; j<events.length; j++) {

  console.log(events[j]);

  request = function(resource) {  // Function that returns a request.
    return gapi.client.calendar.events.insert({
      'calendarId': calendarId,
      'resource': resource
    });
  }(events[j]);  // Bind to the current event.
  request.execute(function(resp) {
    console.log(resp);
  });
}

See the following question for more details on JavaScript arrays and closures: JavaScript closure inside loops – simple practical example

Here is an easier-to-read version of the code above that moves all the processing into a function:

var makeRequest = function(resource) {
  console.log(resource);
  var request = gapi.client.calendar.events.insert({
    'calendarId': calendarId,
    'resource': resource
  });
  request.execute(function(resp) {
    console.log(resp);
  });
};

for(var j = 0; j<events.length; j++) {
  makeRequest(events[j]);
}
Saturday, August 28, 2021
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share