Calendar API v3 Getting Started

900 views
Skip to first unread message

Nick

unread,
Sep 8, 2012, 6:01:32 PM9/8/12
to google-ca...@googlegroups.com
I'm struggling to find adequate Google documentation to lead me in the right direction for what I'm trying to accomplish on a website for a client.  I have years of experience using php, apis, and even facebook website applications.  But for some reason, the Google documentation is cumbersome and I can't find the right route to take and there seems to be no sample projects to illustrate a full working application.

Synopsis of overall goal:  A business's website will access one specific Google calendar used at the business to display appointment slot openings on given website.  Each person at the business has access to the google calendar to add appointments via their google account.  The website essentially needs to access this calendar server side to read the calendar events to determine appointment slot openings so website visitors can schedule an appointment.

I want to use the newest API obviously, Calendar API v3.  I have my project in the API console.  However I am very stumped on how you go about defining and using API access using PHP code server side on the website.  Google want you to use OAuth 2.0, but this seems to force each website visitor to log in via their google account, so a website application can access that user's information.  This is not what I want.  It appears "maybe" the best route would be to use a "Service Account", but that is not enabled for the Google Calendar, and there doesn't seem to be any examples on how to use Service Account credentials anyways.  Other client IDs can be for web application, and installed application (again I don't think these are correct due to user logging in and allowing access to their info).  There is also the Simple API Access using a key for server apps using IP address locking, and a api key for web browser apps.  How do all these relate to Google Calendar use the way I described?  Google insists on using
OAuth 2.0, and older simple REST calls and v1 methods either don't work or will depreciated.  Google does not provide information to guide a developer on what to do, how get this setup and working.  What is proper authorization setup and use for a single Google calendar via server-side php code?

Any information on how to correctly go about this, or point to a API v3 sample would be great.  This seems like this "should" be a simple matter, but for some reason it is incredibly complicated and not fully documented on Google's end on how to do this.

Paul C

unread,
Sep 13, 2012, 7:01:40 AM9/13/12
to google-ca...@googlegroups.com
Take a look at Refresh Token in the Google OAuth section.. Will help you.. User will have to authenticate your site but only once...

William Snell

unread,
Dec 7, 2012, 12:11:40 PM12/7/12
to google-ca...@googlegroups.com
I'm sharing your pain on this one. I'm not a PHP developer (which I'm going to have to rectify), and the library released for .NET has no sample code for the Calendar API. The JavaScript API documentation isn't too bad, but I've been completely unable to get an authenticated request to work. Public calendar queries are easy, but I have found just shy of zero examples of how the code should look for making an authenticated request. The JavaScript library example has code for authentication, but I just can't get it to work (described in my posted question today). So far I'm really digging on the idea of a standardized online authentication protocol, and the idea of the Google APIs, but I wish there was better documentation, sample code, and debugging tools. Their online playground is pretty decent to mess with, particularly if you're running Fiddler2, but doesn't provide a means to enter code, run it, and see why it's not working. I'll post my version if I can get it to work. 

Nick

unread,
Dec 7, 2012, 12:58:34 PM12/7/12
to google-ca...@googlegroups.com
I'm still looking for a solution too.  I'm also a .Net developer, no sample code there either.  If there was, I could use it to translate to PHP.  The furthest I've got so far is possibly using a Refresh Token, which you can make never expire apparently.  You login once at the beginning (on behalf of your webserver?), and then your webserver just takes it from there maybe?  I have yet to find any working code samples.

William Snell

unread,
Dec 7, 2012, 2:03:54 PM12/7/12
to google-ca...@googlegroups.com
OK, I've found an ASP.NET MVC solution posted online that I've managed to get working. Here's the link: http://kelp.phate.org/2012/04/google-calendar-api-with-oauth-20.html. Just a quick note - the ReturnUrl variable at the top of the Home Controller should list something like this: http://localhost:33357/Home/OAuth. This is the same value as is set in your API Console for a "Redirect URIs" entry. I accidentally used the base URL and kept getting redirected back to the home page (doh!). This example successfully wrote to a non-public calendar, but I'm wondering if what I need is a service account.

Nick

unread,
Dec 7, 2012, 2:21:22 PM12/7/12
to google-ca...@googlegroups.com
Through my research, a Service Account sounds exactly like what we need, but from what I found, Service Accounts are not enabled for use with the Google Calendar as of yet, only some other Google Products.  If Google adds Service Account capability to the Calendar, that would be what we would move on to.  Unless they recently added it, it isn't available yet.

Himanshu Jain

unread,
Jul 22, 2013, 7:00:02 AM7/22/13
to google-ca...@googlegroups.com
Hi all,
I am developing my web application in ASP.NET and i am trying to add new feature of Google calendar in my application i.e. subscribe others calendar. So can any help me from this as Google didn't released any documentation over this. If some one implemented this by his own.

Jason P.

unread,
Jun 25, 2014, 6:08:06 PM6/25/14
to google-ca...@googlegroups.com
Service accounts definitely work now for calendar API, at least in order to use the well known "GAM" (Google Apps Manager) to manage calendars.  My first use case was to add a common corporate calendar to all recently added GApps user accounts.  What I'd like to do is add the API calls to do that to our .NET C# provisioning code (running within ILM/FIM).   Basically if someone can point out the Calendar v3 API method needed to do the equivalent of the GAM command like this -- "user [user-account-email] add calendar [email-address-of-calendar] selected true color #234234".  

Any language is fine as long as it shows the general structure of what API methods needs to be invoked.  I've pored over the online docs and I'm baffled how to perform this simple function -- I am a manager looking to farm this to my ILM developer but he is confused too, even though he's done a lot of users/groups API code already.  Any pointers or a link to an example of OAUTH2 login from .NET would be extra cool...another learning curve there I'm sure, he did it for Group Settings but it was a PITA.
Reply all
Reply to author
Forward
0 new messages