Using the Node https://github.com/google/google-api-nodejs-client library I am trying to access public holidays. I have the auth working and have access to the API. When I test the events. list endpoints with API explorer it works, I suspect that the calendar
calendarId :'en.sa#holiday#group.v.calendar.google.com'
exists in my personal calendar but not in the apps calendar.
When I try to get the list of calendars in my node app the list is empty:
calendar.calendarList.list({auth: jwtClient}, calenderGetComplete);
So the events.list doesnt find the calendar.
calendar.events.list({ calendarId :'en.sa#holiday#group.v.calendar.google.com', auth: jwtClient}, calenderGetComplete);
So on a personal calendar, one can add other interesting calendars, like the public holiday one, but seems like you can't do it for the calendar the app is using? Seems like the public calendars don't have 'interesting calendars'?
I am not sure how it is you are authenticating Oauth2 or a service account?
There is a difference between calendar lists and calendars. The calendar list is just that little list on the bottom left-hand side of the google calendar website it has no real purpose (IMO). If you are using a service account and grant it access to one of your personal (ex: chrisMalherbe at gmail.com) Google calendars it will have access to it but it won't appear in the service accounts calendar. list unless you insert it there manually. When you add one of these interesting calendars to your personal google calendar page (ex: chrisMalherbe at gmail.com) the website automatically adds it to the calendar. list for you.
It doesn't really need to be there.
As for public calendars, everyone has access and they don't need to be on the calendar list. They are public you can create a public API key and request data from them. I am not sure what calendar en.sa is but I would take your API key and dump this in a web browser just to make sure there is data. If memory serves there are a few with no data, and the data only goes a year ahead I think so if you are looking for holidays in 2020 there won't be any data.
GET https://www.googleapis.com/calendar/v3/calendars/en.sa#holiday#group.v.calendar.google.com/events?key=[APIKey]
Or with an access token if you don't want to use a public API key
GET https://www.googleapis.com/calendar/v3/calendars/en.sa#holiday#group.v.calendar.google.com/events?access_token=[accesstoken]
I am not a node.js expert but I found this node-google-api it might help I have a tutorial on this its mostly explains how public calendars work however it's in C# may or may not be of any help to you. Public Google Calendars with C#
Related
I am trying to share a service account with any user's calendar and would like to know if anyone knows how to do so on the backend which is node.js or the frontend which is flutter/dart so that the user has to do as little as possible to add the service account to their calendar.
When onboarding a user on the flutter/dart front end I would like to ask a user if a service account can be added to a calendar on their account so the system can handle certain scheduling tasks for the user. I am assuming that the user is not technical. Ideally, I would like to add a new calendar to the user's account and share the service account with that.
After onboarding I would like all actions which the system does with the users calendar to take place on a node.js server using the service account.
I would like the service account to be able to read events from the user's calendar, add events, and find times during which the user is not already booked.
I have searched the internet for many hours and there is very little information about how to do this.
Also, will using a service account to view and modify and find available times on a user's calendar only work with workplace calendars and not with free calendars?
There are services/methods available using Calendar API that can achieve the functionality you want, you may look into the following:
Method: users.list - for listing the users within your organization (as reference calendarId for the other methods needed)
Calendars:insert - for creating a secondary calendar.
Acl: update - for setting Access Control List to the created secondary calendar.
Events: list & Events: get - for listing and getting the specified event needed for modification.
Now, for creating and authorizing the service account for this, you may check this reference link for Authorizing Requests to the Google Calendar API.
Bear in mind that read/write access to events/calendars requires the correct scope as define on the link above.
Here's the OAuth 2.0 scope information for the Google Calendar API:
https://www.googleapis.com/auth/calendar read/write
access to Calendars
https://www.googleapis.com/auth/calendar.readonly read-only access to
Calendars https://www.googleapis.com/auth/calendar.events read/write
access to Events
https://www.googleapis.com/auth/calendar.events.readonly read-only
access to Events
https://www.googleapis.com/auth/calendar.settings.readonly read-only
access to Settings
https://www.googleapis.com/auth/calendar.addons.execute run as a
Calendar add-on
And lastly, service accounts have no rights/authorization to access personal Gmail accounts, since the Domain-wide delegation feature only applies to user accounts within your organization.
Trying to access my personal calendar data using a service account.
I've gone through the setup for creating a service account (with owner permissions). Using NodeJS, I've successfully made requests to my public calendar, but not my private calendars. ( the same result using googleapis and google-OAuth-jwt packages)
Everything that I've searched shows that I need to give "domain-wide authority", BUT, I do not have a G Suite account, so I don't believe this applies to me.
So the question is, can one access their own personal calendar data using a service account? What might I be missing?
You may refer with this SO post. It stated that the service account has its on Google calendar account so if you are trying to read one of your personal calendars, you are going to share it with the service account. You can check the example given using the Json service account key file.
Answer in comments, thanks to abielita. Link to answer.
Remember service accounts are not you. The service account has its own Google calendar account so if you are trying to read one of your personal calendars you are going to have to share it with the service account.
Shared the calendar with my service account.
I have to create a website that has various calendar integrations. Which means the user grants access to the site admin to view/edit his primary calendar. So a real person -secretary- will do this. Not the computer via api calls.
I started off with google-calendar api and got it working w/o any problems.
But I got problems with acl role options. The docs states the role options is a string of either none, freeBusyReader, reader, writer or owner. Is it possible to create composite roles? I want freeBusyReader and write access.
Imagine the scenario a secretary checks the site member's shared primary calendar (via calendar.google.com) and can read all his calendar events. Instead i want to only show that to the secretary that this time of the day in the calendar is taken and you cannot place any events there. But still can place events to non occupied places in the calendar.
I use google-api-nodejs-client to access my calendar on server side application. My app's user is only for me, so I use jwt access via service account.
After setting up a service account on Google Developers Console, I could get/insert events to calendar via google api library. But I couldn't find any events in Google calendar on web browser. Of course I use a same google account for setting service account on developers console and checking google calendar web app.
Perhaps if I use a service account, is a special calendar created? Is it possible to get/insert events from/into my existing calendar via calendar id? I got an error when I set existing calendar id to get events, 'Not found'. I could only set 'primary' as a calendar_id.
I got an answer by myself. If I use existing calendars, I have to set 'sharing settings' to each calendar in google calendar.
Open google calendar
Go to calendar setting page
Open 'share setting' that calendar you want to use
add your service account email (xxx#developer.gserviceaccount.com) and set authorization level.
Then, I could access existing calendars!
I'm looking to get check-in data that includes user ID, place and time information, from Foursquare users that have public accounts. What is the best way to do this that doesn't require each user's authentication? Thanks.
I'm afraid that's just not possible using the API. In order to access checkin information a user must authenticate with your app.
If you don't need specific users, you can search Twitter for Foursquare checkins published there and then scrape the linked checkin pages for the user ID, place and time information.