Access to a public calendar using the Google APIs without requiring a user to log in

I want to access the public calendar using the Google REST API.

The Google Calendar API offers me to use the OAuth token for accessing calendars:

https://developers.google.com/google-apps/calendar/auth

However, I get access to the public calendar and do it from the server, so I can not / should not / should not ask the user for authentication.

I am using node.js api:

googleapis .discover('calendar', 'v3').execute(function(err, client) { client.calendar.calendars.get({ calendarId: '***@group.calendar.google.com' }) .execute(function (err, response) { console.log('response from google', response); }); }); 

This returns "Your client issued a wrong or illegal request. That's all we know."

Calling .withApiKey('***') after .calendars.get() returns the same error.

Any suggestions?

+8
google-calendar google-api google-api-nodejs-client
source share
3 answers

As indicated in the documentation more than once

All requests to the Google Calendar API must be authorized by an authenticated user.

Therefore, if you want to use the Google Calendar API, you need an authenticated user. This can be easily achieved with modules such as Passport.js and Passport-google-oauth .

However, if you can put aside the API for a moment and

  • The calendar is open.
  • You want read-only access.

You can easily get a shared address and use the calendar via ical, xml or html. Take a look at the UK calendar calendar: http://imgur.com/UGjPtqp

You can publish data publicly:

At this point, it is trivial to get such resources using node and get the data you need.

+12
source share

Oh guys! You can receive data without OAuth without requiring the user to log in while the calendar is configured as open! I tested it myself.

 $.ajax({ url:"https://www.googleapis.com/calendar/v3/calendars/" + cal_id + "/events?key=" + api_key, success: function(data) { console.log(data); } }); 

Just try it.

The documentation is here https://developers.google.com/google-apps/calendar/v3/reference/events/list#examples

+6
source share

Google must have an authenticated user, but since this is a public calendar, you do not need to request authentication from the user. This is the server side, so use your own authentication (or create a Google user for this only for that), and as an authenticated user, you will have access to this calendar without asking for a genuine user to authenticate ...

0
source share

All Articles