One of my first assignments when I arrived at Nuxeo was to build a plugin for a time off request workflow, based on the Nuxeo Platform, of course!

The Challenge: Enter Time Off to Google Calendar Automatically

No work beyond this pointWhen a Nuxeo employee wants to take time off from work, the first step is to complete an Intranet request form. Once the request is submitted, it is routed to the employee’s manager for approval. The request is then sent on to the human resources department to validate the request and send an email confirmation back to the employee.

The HR team had to go through a cumbersome manual process of creating an event on Google Calendar, setting the beginning and end date of the time off, etc. So the idea was to automate the publication of the event on the HR’s Google Calendar using an automated operation once the time off request is accepted.

The Operation: Using Google API

After digging into the API offered by Google to use offline publication, I created a simple operation that fetches an authorization token (explained later) and pushes the event to the user’s calendar, all via the API. The operation takes several parameters:

  • userEmailAddress: the user’s email where an event will be created
  • summary: the title of the event
  • location: the location of the event
  • description: the description of the event
  • startDate: the start date of the event
  • endDate: the end date of the event
  • attendeeEmailAddress: email address of the attendee (employee who made the time off request)

Authorization: Using OAuth2

There are several ways of being authenticated to use a Google API on behalf of a user. The one I focused on was OAuth2 because everything was implemented in the Nuxeo Platform to handle the authorization token generated, including a dedicated UI with the corresponding button.

All I needed to do was extend the authorization scope of the existing Google API provider under The Admin>Cloud Services>Services Providers part by adding: email,’s it!

For more details on how to configure a service provider, check out this documentation.

In the previous operation, I used the following method to retrieve the authorization token of a user:

protected String getAccessToken(String user) {
    OAuth2ServiceProvider serviceProvider = Framework.getLocalService(OAuth2ServiceProviderRegistry.class).getProvider("googledrive");
    Credential credential = serviceProvider.loadCredential(user);
    if (credential != null) {
       String accessToken = credential.getAccessToken();
       if (accessToken != null) {
           return accessToken;
    return null;

Final Step: Nuxeo Studio

After adding the definition of the operation in Nuxeo Studio, I went through the automation part and ‘drag and dropped’ my newly created operation to the last action of the time off request workflow.

Notification > Publish on Google Calendar

That way, when the HR rep accepts the time off request, this operation will be launched immediately with the contextual information of the workflow.

Time For Some Automation Magic…

Now let’s play the role of an HR Manager. The first thing you need to do is give the authorization to Google API to grant the publication on your behalf via the button that you’ll find under Home > Cloud Services > Connect to Google

Accept offline accessAccept offline access

Once you accept the offline access the authorization token is saved in the Nuxeo Platform and the operation will now be able to retrieve it. This is a one time action of course!

Then, every time you validate the pending task of the workflow the magic happens.

Approve timeoff requestTime off request approval

An event has been automatically created on HR’s calendar.

Event published in HR's calendarEvent published in HR’s calendar

The source code of the plugin is available here (tested and validated on nuxeo 7.3 FT). So, go ahead and play with it! Don’t forget to give me your feedback!