Cross-calendar integration (Google Calendar & Outlook Calendar) - google-calendar-api

I'm working with Google Calendar(GC) and Outlook Calendar(OC) APIs.
Let's say a GC user invites an OC user to an event created in GC. When creating a new event in the OC user's calendar, the OC API creates a new event ID instead of using the existing GC event's ID. What this means is that there's no unique identifier for the two events and they might as well be different events. My application needs to connect the two events.
Currently the OC calendar API says the Id field is not writable. The GC API allows a writable event id but not for cross-calendar invites (since the event creation is happening inside the guts, is not directly called by my app).
Any ideas / suggestions? Many thanks!

Related

Google Calendar Push Notifications: New events and event validation before/after creation

I would like to now if the following functionality is supported by google calendar api:
Does the functionality provided by "Push notifications" include new events or just existing ones. Here is a copy paste from the documentation that let me doubt that new event notifications are supported "The Google Calendar API provides push notifications that let you watch for changes to resources.". So does this only apply to already existing resources (events on my case).
Is there a way to limit the availability on the google calendar. By this I mean setting a general limit (i.e working hours for a company for example from 9am to 5pm). And putting the logic further, is there a way to add more constraints. For example after I receive a notification of a new event created (if this functionality is provided), I check the event's data in my web-hook and let google calendar know that this event shouldn't be considered as valid.
If these requirements are not provided already by google calendar API, I am open to any suggestions to accomplish this even if it takes more coding.
Just to make it clear. The context of these questions is when the user creates an event in their google calendar through google calendar web interface not through my application.

Listener for Google Events

This other question suggested using webhooks to listen for an event. Google Calendars API - Listener for new calendar events or updates to existing events?
As the admin, I need to listen for new, updated or deleted events in all my users calendars. Once alerted then I will take the event information and then do something with it in another business software application.
How can I use the webhook to not just listen for a events in a single user's calendar but in all calendars?
You have to create a resource for each Calendar. You can do it using the Directory API to fetch all the users and their respective Calendars:
List all the users in your domain.
Get the primary email of each user, which is also their Calendar Id.
Use a for loop to iterate over the emails and make a POST request:
POST https://www.googleapis.com/calendar/v3/calendars/my_calendar#gmail.com/events/watch
If this is not feasible, you can request this feature on Google's Issue Tracker.

Google Calendar API: User exists as an attendee when the meeting does not exist in his calendar

I'm using calendar API to pull events of users in an organization that had installed my GSuite app as a service account (it just means that I have access to all the users in the organization).
I noticed some weird behavior - let's say I have an event with 2 participants - a and b (both are users in the company). when I use the calendar API events.list to pull event for a I get this event, and b is listed in the attendee list with responseStatus of 'accepted'.
When I pull the events for the same period of time for user b, I do not get this meeting, nor when I try to pull a specific event using the meeting id (event.get API). I also used showDeleted=True but still didn't get the event back when pulling the events of b (I'm pretty sure if the event would have been deleted then the responseStatus would have been 'decline').
What could be the reason for this behavior? I tried to reproduce it using two emails that I have access to, and I was not successful.
Since those are emails of my client I cannot just come up to them and ask what happened with this meeting.
This is the request I'm making (using python google API client):
from googleapiclient.discovery import build as Build
service = Build("calendar", "v3", credentials=credentials, cache_discovery=False)
service.events().list(calendarId='primary', timeMin=min_time, timeMax=max_time, pageToken=page_token, singleEvents=True).execute()
First I'm building the service using the service account credentials (delegating permissions to the current email), and then making the request to pull the events.
The min_time,max_time are strings like this - 2020-10-19T08:00:00+0000.
The pageToken starts as None but will change if there is a nextPageToken in the response.
This is the request I made to try and get the meeting of the user that appear as an attendee when pulling the event using another user's email & credentials:
service.events().get(calendarId='primary', eventId=<meeting_id>).execute()
But I'm getting 404 event not found response (This API returns deleted events - I've seen it)
I'm pulling all of the events correctly, and only saw this case on small number of the events (less than 5% of the meetings).
Any idea what could cause this?
Thanks!

Firebase Analytics: first_open event missing for part of my users

I'm creating some funnels and journeys for my app's events from Firebase Analytics using BigQuery, starting with first_open and continuing with other custom events. My understanding is that using user_pseudo_id, I should be able to track a single user's journey.
The problem I'm facing is that some user_pseudo_ids found in the custom events do not have a corresponding first_open event, so I'm not sure when they started using my app.
Are there cases where a first_open may not be recorded? Or cases where the user_pseudo_id may change after first_open?
TL;DR: In order to reliably track users, one should use setUserId().
As noted in this answer, user_pseudo_id comes from getAppInstanceId(), and it's reasonable to assume its lifetime is not dissimilar to FirebaseInstanceId, which can change in the following cases:
App deletes Instance ID
App is restored on a new device
User uninstalls/reinstall the app
User clears app data
Reinstalling triggers the first_open event again, so that wouldn't be my case, and my app does not delete the Instance ID.
Going through the logs, the last option can be discarded (in my case), because I can see the users were logged into my app when the new user_pseudo_id started being used.
So that leaves restoring the app on a new device as the likely culprit.
I'm now using setUserId() in order to track users.

Google Calendar push notifications. Up to date flag

I've subscribed on google calendar push notifications (PN). Base synchronization processes using PN. I need to know if all events already loaded in calendar scope or not.
Is it possible to have a special marker in my request answer (request events for specified calendar based on subscribed channel information)?
If calendar has too much events, events will be loaded in few push notifications handling. I need marker for UI if calendar is synchronized completely. In my my usual logic I thought that calendar is already synchronized if first PN per calendar already handled. So I need notify my UI client with correct status (calendar_is_synchronnized, calendar_is_not_synchronnized) but I do not have any markers from google if the PN provides me load last events portion in specified calendar scope.
I haven't got elegant solution for my question. But I've solved issue with double call. The is no special API for this purpose, I've used algorithm:
after updating to sync token I try get all events for same calendar just to be able compare new nextSyncToken with current if it is the same.
if token is different if means the calendar sync is not completed yet.
If any better idea(s), you are welcome.

Resources