Calendar Widget with SmartVISU is back!

On 17th November 2014, Google closed its V1 and V2 APIs:

The Google Calendar API moved to version 3 months ago; however, many developers have continued to hang on to v1 and v2 integrations. In less than a month, on Nov. 17, Google will shut down v1 and v2 in accordance with itsDeprecation Policy. Google has published an entire Migration Guide to assist developers’ transition, and many third-party solution providers have released packages to further streamline the process.
This meant that the Calendar widget on SmartVISU was no longer working.
CarGo kindly created a guide on how to create a V3 API so the calendar would work with SmartVISU.
Trouble is, CarGo wrote it in German, so I’ve translated it below. It may sound complicated, but then it’s only required once 🙂

  1. Log in to the Google Developer console:
  2. Create a “Project” -> You can simply enter “Project API”, unless you’re planning on creating many APIs / Apps, it does not matter at this stage
  3. On the left menu, select “APIs” then “Calendar API” on the main page.
  4. On the left menu, select “Credentials” then click on  “Create new Client ID”
  5. Important: Select “Installed applications”, NOT Web Application – otherwise you’ll have to grant access each time in a pop-up…
  6. On the left menu, select “Consent screen”. The main info to provide here is the Product Name. I called mine SmartVISU.
  7. Select “Installed Application” then “Other” for application type, and finally “Create Client ID” .
  8. Now under “Credentials” from the left menu, “Client ID”, “Client Secret” and “Redirect URIs” are displayed. We’ll need these in the next steps

The access details are now configured. The trick is to create an “Authorization Code” and “Refresh token”.

To do so, download and extract it in “[path]/smartvisu/lib/calendar/service”.  (Replace [path] with the path to access your SmartVISU folder)

Make sure the file owner is www-data else you’ll get errors. To make www-data the owner, simply enter the below in a terminal:

chown www-data [path]/smartvisu/lib/calendar/service/google*
  1. Getting the “Authorization Code” and “Refresh token”:
    1. Enter the values ​​for “ClientID” and “redirect URI” in “google_1.php”
    2. Paste the below command in the terminal
    3. php -q google_1.php
    4. Click on the link in the terminal (you may need to hold CTRL while you click)
    5. Confirm you want to grant access to your Google Account
    6. Copy the “Authorisation Code” displayed
    7. Enter the values ​​for “ClientID”, “Client Secret”, “redirect URI” and the code copied from above step in “google_2.php”
    8. Paste the below command in the terminal
    9. php -q google_2.php
    10. Keep note of the provided “Refresh Token”.
    11. Edit “googleV3.php” and replace the blanks for:
      1. “ClientID”
      2. “Client Secret”
      3. “Redirect URI”
      4. “Refresh Token”

Last but not least, edit config.php in your main SmartVISU folder and add replace your google calendar line with the new script:

define('config_calendar_service', 'googleV3');


Save,  Et Voilà !

Massive thanks to CarGo for the original work and guide.

Google Calendar Widget V3 API

Google Calendar Widget V3 API

PS. There may be a need to refresh the token in the future. I’ll post an update as and when it occurs. If this happens, Ideally the refresh should be automated, but that’s a story for another time 😉