Sync / Share Google Calendar & Nextcloud Calendar

Hi,

Just sharing something i found useful.

context : i am using nextcloud calendar, my wife is still using google calendar. i want to see her calendar (read only) in nextcloud and she wants to see mine (read only) in google.

easiest solution : get her to use your nextcloud server’s calendar !!! :slight_smile:

if for some reason, she does not want to, keep reading.

sharing a google calendar in nextcloud :

  • connect to the google calendar to be shared
  • click on the dented wheel on the top right, to open settings
  • on the nav bar on the left, scroll down to “settings for my calendars”, then develope menu for the calendar to be shared
  • scroll down to “integrate calendar”
  • look for "secret address in ical format and click on “copy” icon
  • head back to nextcloud calendar app
  • click on the plus sign next to “new calendar” on the left nav bar
  • then click on "new subscription from lin (read only)
  • copy paste the link from google calendar, then validate
  • after a few seconds, events from the google calendar should show up
  • profit !

sharing a nextcloud calendar in google :
you could use the subscription link from nextcloud and add it to your google calendar… but as google only refreshes external calendar not so frequently (like every 24 hours), this is not really a satisfying solution.
after a long time googling for a solution i found this : GitHub - derekantrican/GAS-ICS-Sync: A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
as explained in the read me :

  • copy paste this script to your own google app script interface
  • edit the script and modify some values :
  • line 21 paste the subscription link from your nextcloud calendar and choose the calendar name that will appear in google calendar
  • lines 24 to 39 review options and modify as needed (especially refresh interval, by default : 15 min)
  • on the top menu select “install” function", then click on “run”
  • on the top menu select “startSync” function, then click on “run”
  • you will need to grant permissions for this script to edit your calendar
  • after a few seconds events form your nextcloud calendar should show up on your google calendar

nb : obvisouly you have to make sure google can access your nextcloud instance. for example, i had set uo cloudflare in front of my instance to block connections from other countries than mine. i had to add a rule allowing google AS before the rule blocking all countries but mine.

9 Likes

Thanks a lot for this helpful thread !

Sadly, it doesn’t seem to work for me. After roughly 24 hours, changes I made in gcal are not synced to nextcloud-calendar. This seems to import gcal, but no sync. Any advice?

best regards

Default subscription refresh rate is of one week.
https://docs.nextcloud.com/server/latest/admin_manual/groupware/calendar.html#subscriptions

1 Like

Hi all,

@nicooo @Gorom @muck @tcit
be aware that sharing like this does not include encryption nor authentication.
So you basically share plain text the calendars (nextcloud and google) to everyone who got the link somehow and every knot on the internet can read it too.
It is meant for public calendars (like concert events).

A secure solution is to make a google / apple account and use for example outlook and caldav to sync between the instances. This is not a superb solution but the only I am aware of which offers security and authentication. If anyone is interested in a more detailed description drop a note.

1 Like

Hi all

On android:
Use DAVx to sync Contacts & Calendars with your android calendar (like google calendar)

Ohaï !

Thank you so much @nicooo !

For your **sharing a google calendar in nextcloud ** method, do you have any way or idea to make this work with private calendar that needs credentials ?

I tried to find documentation on how I could add them credentials in the url (which I guess is a very bad security habit even if https), or if there was any pop-up/window prompt functionnality to ask for credentials within Nextcloud but meeh

╮(─▽─)╭

If anyone have an idea that would save me, thanks again !

Hi, you can suscribe to a private google calendar without credentials with ical the private link…

I just add this hack to do if you sync a google calendar on your Nextcloud Calendar.

The refresh rate of a calendar subscription in Nextcloud is once every week by default.

https://docs.nextcloud.com/server/19/user_manual/pim/calendar.html

Subscriptions are refreshed every week by default. Your admin may have changed this setting.

Change the refresh rate:

  • Connect with a terminal in ‘root’ to the Nextcloud instance.
  • Position yourself at the root of the Nextcloud site.
    cd /var/www/nextcloud.example.com/www/ # For example
  • Get the owner of the ‘config.php’ file.
ls -l config/config.php
.rw-r----- nextcloud nextcloud 1.5 KB Wed May 25 10:17:35 2022 config/config.php
  • Change the value of the ‘calendarSubscriptionRefreshRate’ option of the Nextcloud calendar app to 5 minutes.
sudo -u nextcloud php8.0 occ config:app:set dav calendarSubscriptionRefreshRate --value "PT5M"
# Résultat :
# Config value calendarSubscriptionRefreshRate for app dav set to PT5M
  • Use the user who owns the config file.php with the sudo command. Use the php binary corresponding to the Nextcloud version.
  • Check the consideration.
sudo -u nextcloud php8.0 occ config:list | grep -i calendar
# Résultat :
#        "calendar": {
#            "calendarSubscriptionRefreshRate": "PT5M",

Crontab

  • Edit the crontab of the user who owns the config file.php seen above.
sudo -u nextcloud crontab -e
  • Add a task every 5 minutes running the php script located at the root of the Nextcloud site.
*/5 * * * * php8.0 -f /var/www/nextcloud.example.com/www/cron.php
  • Use the php binary corresponding to the Nextcloud version.
  • Log in as ‘admin’ on the Nextcloud web interface. Then go to Settings.
  • In the Administration section at the bottom left, go to Basic Settings.
  • Ensure that Background Tasks are configured with ‘Cron’.
    469843cdec6eff1063dff5d85c2f4f1be470e429_2_690x173

Sources

Nextcloud : Ajouter un calendrier Google privé (Sans credentials) | Aukfood
Using the Calendar app — Nextcloud latest User Manual latest documentation
Calendar / CalDAV — Nextcloud latest Administration Manual latest documentation
PHP: DateInterval::__construct - Manual

1 Like

Hi @rodinux ,

Can you eleborate what makes a private ical link different from an ical link?

I am unsure what the hack is. You change the refresh interval as described in the Admin documentation too.