About the Google2 plugin

The Google2 plugin was developed because Google deprecated their version 2 calendar and documents (Drive) API. Since the original Google plugin supports more than just the calendar and documents API, this plugin has been named Google2. More APIs might be added when there is demand for it.

Main differences to the original Google plugin


The plugin has been compiled against Servoy 7.4, but it should work with any Servoy version >= 6.1


The Google2 plugin no longer uses the so called client login authentication mechanism (using username and password), but OAuth authentication. While this makes authentication more complicated, it is safer and more elegant once implemented. You no longer have to store a user's Google account password, but only an access token.

The basic workflow is this: your application presents the user a URL where he is asked to login to his Google account (when necessary). The user will then be asked whether he wants to allow the application xy to access his calendar. When the user allows that, he is presented a code (token) that he needs to copy. That code can then be used to authorize your application for the user's account using a method of the plugin. When successful, the plugin returns a token that you need to store. With that token you can then access the user's calendar service.

1. Registering your application

When the user is asked whether he wants to allow application xy access to his calendar, that application should be your application. To make that work, you need to register your application with Google. If you don't do that, the name of the application will be "Google plugin for Servoy" (the plugin's default). If that is fine for you, you can skip this step.

To register your application follow these steps:

  • go to and create a project with the name of your application
  • open your project and go to "APIs & auth"
  • go to "APIs" and enable at least the Calendar or Drive API
  • go to "Credentials" and create a new client ID for an installed application
  • this will give you a CLIENT ID and CLIENT SECRET for your application

Before you want to access any Google service, you should then call

plugins.Google2.setupApplication(applicationName, clientID, clientSecret)

2. Authorizing your application

Your application needs to open a URL where the user is asked to grant your application access to the user's calendar. That URL can be created using


For the time being, the Google2 plugin only supports the Calendar and Drive API, so scopes can only include any of the two (or both)


Once the user logged into his account and granted the requested access, he will be presented with a code (token). That token is then used to authorize your application:

plugins.Google2.authorize(code, userId, scopes)

Please not that the code has a validity, so it will expire rather quickly. The result of the method is the refresh token that you need to store.

3. Accessing the Calendar, Drive ot GMail service

To finally access the service, use






Other differences

Obviously a few things have changed on the Google side. We have tried to make the plugin as compatible as possible with the old version. Quite a few methods have been deprecated or moved. Almost all deprecated methods will still work, but should be refactored. When you hold down the ALT key while hovering over a deprecated method in the JavaScript editor, you should see the @deprecated tag that should explain what to use instead.

Some of the major changes on the Google side are these:


Reminders no longer takes days, hours and days before, but only minutesBefore. So if you want a reminder to occur two days before the event, calculate that to minutes. The old methods should still work however.

Calendar.getEventsModifiedBetween() is deprecated

That method is replaced by getEventsModifiedAfter. The old method still works, but doesn't consider the end date you provide.

Saving events

Before, there was a method CalendarService.updateEvent(event). That has now been moved to the Event object (Event.update()).


Most objects like Calendar or Event have a method getJSON() that will return the JSON sent to or received from Google. This is a good way to find problems.

some properties are no longer updatable

Some properties as for example the color of a calendar cannot be updated right now (not implemented by Google), but can be set when creating a calender before it is saved.


The Google2 plugin now makes use of Constants where useful. Make sure to check them out.