Reputation:
I'm developing an Android app that uses a service to read Google Calendar events. It is working (not as desired) with Google Calendar API v2 (that is deprecated) and now I'm trying to implement the Google Calendar API v3.
I've been following this sample (http://samples.google-api-java-client.googlecode.com/hg/calendar-android-sample/instructions.html) but now I've realized that I don't need to use OAUTH2.0 in this application. I don't want to ask permissions to the app user to access their Google calendar, I want to show calendar events from a common calendar.
In Google Calendar API V2 I could just use the private calendar URL like this:
https://www.google.com/calendar/feeds/{EMAIL}/private-{MAGIC-COOKIE}/basic
Can anyone tell me if it is possible to still use the same calendar URL to just read the events without using OAUTH?
Upvotes: 3
Views: 5669
Reputation: 1493
With V3 it is possible to read events on a public calendar without Auth, but you will need an API key and you will have to declare your site domain. Try this url in a browser :
https://www.googleapis.com/calendar/v3/calendars/{YOUR AGENDA MAIL}/events?key={YOUR API KEY}
If you want to get the events after 1st of Jan 2017 you can try this :
https://www.googleapis.com/calendar/v3/calendars/{YOUR AGENDA MAIL}/events?key={YOUR AP}&maxResults=2500&orderBy=updated&timeMin=2017-01-01T00%3A00%3A00%2B00%3A00&singleEvents=TRUE
maxResults default value is 250
timeMin is a RFC3339 timestamp (url encoded). In php you can generate it like this : urlencode(date('c'));
All parameters are explained here : https://developers.google.com/google-apps/calendar/v3/reference/events/list#try-it
NOTE : If you don't know how to get a API key you can follow this wizard : https://console.developers.google.com/flows/enableapi?apiid=calendar
Upvotes: 0
Reputation: 116868
What you are looking for is a Service account. Service accounts let you set up a standard calender that all of your users will use. Its diffrent then the normal OAuth the users wont be asked permission to access there own account. They will be accessing your applications account.
Here is a link that should get you started.
https://developers.google.com/accounts/docs/OAuth2ServiceAccount
Upvotes: 2