Google Calendar API Get Events from Other Calendars - google-calendar-api

I'm extending a PHP application that allows managers to create events and assign specific users to those events. Before the user is listed as available to be assigned, however, I run a check against the user's calendar to see if they are available.
I've already built this once for Exchange using EWS and making use of FindItem method to retrieve events in a given timeframe for a user's email address, but I'm having trouble finding an equivalent in the Google Calendar API.
Both Events and FreeBusy Calls seem to require the specific user's calendarId, which is fine for retrieving the active authenticated manager's Calendar information, but not for their users, of which only the email address is currently available to my system.
Is there a way to retrieve events or a calendarId for a user based on a valid Google email address? (Or is there a better way to get other user's FreeBusy status that I've completely overlooked in my research?)

The Calendar API is a REST API that can be accessed through explicit HTTP calls or via the Google Client Libraries. However, please note that all requests to the Google Calendar API must be authorized by an authenticated user.
User's calendar list can be obtained through HTTP request:
GET https://www.googleapis.com/calendar/v3/users/me/calendarList/calendarId
Code examples for supported programming languages can be found in CalendarList: get.

Related

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!

Delete without ClientID - User Deletion API Google Analytics

I have a question regarding User Deletion API for Google Analytics. We have a Property and View that does not collect UserID or ClientID as Custom Dimension, but we have a lot of PII data in our Events report (emails and phone numbers).
When i go to User Explorer i can get the ClientID, but unfortunately as far as i know this report is not available in any API versions of Google Analytics.
My question is HOW can i then delete all these PII without knowing the ClientID? I do not have a 360 account.
Unfortunately I think you've done your research correctly and I'm afraid there aren't more options available than what you already listed:
You have 2 ways of deleting data:
User Deletion API
Deleting views (I know it's too radical, but that's the only other option)
As for option 1, indeed, none of the reporting APIs expose the Client ID or the User ID, so you have 2 options:
Export the Client ID manually from the User Explorer report, but you won't be able tell which PII is associated with which Client ID
Implement a custom dimension to store the Client ID so you can then identify the corresponding PII, and automate that process if you want to

Get Google Analytics Data without Client Secrets

I am looking to make a web based app which creates a monthly report that has Google Analytics information in i.e. organic searches etc. Some clients will have their own Google Analytics accounts and wont be own mine.
I managed to get the OAuth 2 authorization working with my account however it wont work for clients as I needed to get the client_secret.json file from Google Developers website. I have seen a service like cyfe.com which just gets the google login information and outs the Google Analytics information in graphs and such.
Does anyone know how they manage this is possible without getting the client_secret.json file ?
oAuth2 is designed to let you access to users data with their permission, without requiring to access their password.
You should use your own client Id and client secret, these identify your application, not your users ("client" here means client of the API).
You then need to create an interface where users can allow your application to access to their data, from this you'll get an access token, allowing to your application to access to Google Analytics data of your user on their behalf.
Read "Using OAuth 2.0 to Access Google APIs", and identify the scenario that matches to what you want to achieve.
I strongly suggest that you use a library managing the authentication flow, you don't need to reinvent the wheel. Here's a list from Google: Google API Client Libraries.

Getting Shared List (gmail address)- Google Calendar API

I am using Google Calendar API through OAuth.
So far, I would like to access events which are shared from other users.
For example, test1#google.com calendar is shared with test2#google.com
For this situation, I could access test1#google.com and test2#google.com calendar events, using access token of test2#google.com. I feel this is a bit dangerous in terms of security because I can see some events of test1#google.com without test1#google.com's permission. I need just access token of test2#google.com.
Anyway, it is not a point. The problem is how I can get gmail address information of users who are shared, i.e. in this case, test1#google.com address, from test2#google.com information.
I came up one way to get shared list, but it is not official.
I would like to use some official API to get Shared List.

Combining Google Analytics client- and server side tracking

I track my users behavior using Google Analytics client side. At some point the user is redirected to one of my partners and I receive a callback from the partner about the value the user has generated.
The question is: How do I append that value from the callback as a goal with a value to the users session?
The objective is to be able to get insights about which of my traffic sources generate the most value (and not just most conversions - as that could be tracked with event tracking).
The solution might be similar to this one, but I'm not sure it's still the best solution - and there could be others as well.
Using Google Analytics to track the same session in client javascript and server side tracking calls?
Thanks in advance.
So it seems that this is now possible with the new Universal Analytics from Google by saving/syncing the users UUID to the server and then tracking any relevant events.
https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
This package seems like a nice wrapper: https://www.npmjs.org/package/universal-analytics
Another option is to use same userId (not clientId). That works for multi-device tracking https://support.google.com/analytics/answer/3123662
Universal-analytics is better in that you can use it for anonymous users as well as signed-in users
But tracking by userId is better in that you can send events even if user is not currently on your website doing http or websocket requests.

Resources