How do I access other users calendars with google calendar v3? - google-calendar-api

I am using the Google Calendar (v3) API, with google apps and am wanting to use a single oauth2 credential to determine what users are free/busy at any given point.
I am wanting to use this:
https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query
But to use this I need to get all the calendar ids for all the users. I cannot do this as the java client for the google calendar can only retrieve calendars of the user who owns the credential.
Note: I have access to all the users through the provisioning api.
Any help would be much appreciated as I am totally blocked by this.

For primary calendars, the calendarId is the user's email address. The authenticated user will also need to have permission to access the calendar. If you're using the Provisioning API then I'll assume you are a super admin, and super admins can access every calendar on their domain.
The specific query you are trying to do takes a list of calendarIds to query as a JSON list. If you are only concerned about primary calendars, then set each user's email as an id like this:
"items": [
{
"id": "user1#example.com"
},
{
"id": "user2#example.com"
}
]

In 2013, I took about a week to integrate with Google Calendar.
There were several steps:
ESTABLISH CREDENTIALS
GET CALENDAR OWNER AUTHORIZATION
RETRIEVE AUTHORIZATION CODE
REQUEST TOKEN
RETRIEVE TOKEN
GET CALENDAR ID
UPDATE THE TOKEN
RETRIEVE CALENDAR ENTRIES
I described the steps in more detail in 2013, now web archived here: https://web.archive.org/web/20130215064337/http://www.tqis.com/eloquency/googlecalendar.htm#DOC77

Related

Google Analytics Data API (ga4) obtain email or username current user who call

in universal analytics you can obtain easily the username, you receive the username in a basic call, I use that username so while I migrate to GA4 I wonder where is that data, I can consume severals endpoints but the most close was Account.UserLinks but that retrieve all user linked with an account but not say which user am I. I try add different scopes but nothing, any ideas?
scopes used
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.manage.users.readonly
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile
Also Accounts don't provide that data
{
"name": "accounts/6666",
"createTime": "2018-11-16T18:27:26Z",
"updateTime": "2019-08-13T21:17:12.851Z",
"displayName": "Dummy",
"regionCode": "PR"
}
I already know how obtain from universal but I only want use GA4 new api
thanks in advance
You can get the signed in user's profile information using the Google Sign-In JavaScript library or the new Google Identity Services.

Google Calender API: Possible to store events in own private calendar?

I am currently writing an online-booking-module and I want to store events (beside in the database) in a owned google-calendar (this calendar is then added to the responsible employee in outlook).
My idea was just to give the API my auth-data and the calendar-id and then being able to insert and delete events.
The calendar must be private, not public!
Now I see it is more designed to access user's calenders getting their permission etc...
Answer:
Yes, you can authenticate the application as yourself and add the events to a private calendar owned by you.
More Information:
Once the application has been published and contains your credentials and token, there will be no issue running the Events add Calendar API method as you, regardless of who runs the program.
Other option:
Alternatively, you could create a Service account to impersonate your account and run the calendar API queries, though you would need to provide the Service Account with access to your private Google Calendar.
References:
Google Calendar API - Events: insert
Authorizing Requests to the Google Calendar API
Google Developer Admin Console
Google Cloud - Service Accounts
Understanding Service Accounts
Creating and Managing Service Accounts
Creating and Managing Service Account Keys
Granting Roles to Service Accounts

send google oauth email and password

I'm using oauth to authenticate in google calendar, but i'm trying to send user and password to avoid open the authentication popup.
I'ts like automatic authentication.
Is it possible?
Thanks.
Since you want your application to always create events in a single calendar that is under your control, here is how I would do it:
Create a service account in Google Cloud Console - recent instructions on how to do so can be found here: google oauth2 how to get private key for service account
Share your calendar with that service account: https://support.google.com/calendar/answer/37082?hl=en
Write your code to use the service account credentials (private key downloaded in step 1).
I didn't post any sample code, as I'm not sure what language you are using. The following has some discussion of this use-case in PHP: Access Google calendar events from with service account: { "error" : "access_denied" }. No google apps

Google Calendar Api not returning attendee name for directory contacts

I have built a web application that uses a service account linked to my own Google Account. We use Google Apps, so my Google Account is part of a domain. We have a server with shared contacts, so all of our clients are available as contacts for everyone. In my contacts, this group is called 'directory'.
The application retrieves events from the Google Calendar using the Google Api PHP client. It also retrieves attendees inlcuding all details for those attendees. But if the attendee is not within our domain, it will only retrieve the e-mail address. I also want to get the name for that attendee.
These names are in my contacts in the directory group. When I create an event and invite guests, I can retrieve these contacts and it will show the name and mail adress. But when retrieving the attendees via the API it does not show these names.
Is this a restriction of the API? Is there a solution for this?
I do not want to use the Contacts api with a non-service account, because I don't want to give permission everytime. It is not possible to use the Contacts api with a service account as far as I know.
You are correct that a service account won't work with the Contacts API, however you don't have to authorize it every time you use it. You can provide domain-wide delegation with two-legged OAuth 1.0a instead of 2.0. See https://developers.google.com/google-apps/contacts/v3/index#authorizing_requests_to_the_+wzxhzdk8+_service and https://developers.google.com/accounts/docs/OAuth#GoogleAppsOAuth.
Depending on your setup, you can also use the three-legged OAuth 2.0 flow for a single administrator account and save the refresh token. This would let you re-use that authorization without requiring explicit permission again.

Retrieve Google Calendar owner's email address

Is it possible, with the Google Calendar API / Zend Gdata, to get the user's google email address, after he successfully authenticated with AuthSub and I have an access token?
I have a problem with some users having multiple Gmail and Google Apps accounts, and then not remembering which one they've used to Sync with my service and having the impression that the sync doesn't work. I'd like to display them the Google Account they have first authenticated with.
Have you tried the experimental settings API? It looks like it returns the user's name and email address in the author section.

Resources