Google Calendar – How to Get a Link to Add a Calendar

google-calendar

I'm aware of the following methods of adding a Google Calendar:

  1. Show embedded calendar, hit the +Google Calendar button:
    1. Go to Calendar Settings.
    2. Copy the "Public URL to this calendar" such as https://calendar.google.com/calendar/embed?src=foo%40example.com.
    3. When the user taps the link, they will see an embedded version of the calendar. They would then tap the bottom right +Google Calendar button and it'll be added to their calendar.
  2. Give the user the "Calendar ID" email address:
    1. Go to Calendar Settings.
    2. Under "Integrate calendar," copy the "Calendar ID" such as en.christian.holiday@group.v.calendar.google.com
    3. The user would then open their Google Calendar, and under "Add a friend's calendar," they would enter that long email address.
  3. Add a shared resource:
    1. Hit the plus button near "Add a coworker's calendar"
    2. Hit "Browse resources"
    3. Add a calendar from the list

However, all of these methods are multi-step and less than ideal. I just noticed that there is a 3rd, more optimal way. There's an ability to create a link of the form https://calendar.google.com/calendar?cid=ZW4udXNhI2hvbGlkYXlAZ3JvdXAudi5jYWxlbmRhci5nb29nbGUuY29t. Upon tapping on a link like that, it displays the calendar in the user's google calendar (or prompts them to add the calendar).

I tried substituting my "Calendar ID" in place of the "cid," e.g. https://calendar.google.com/calendar?cid=en.christian.holiday@group.v.calendar.google.com but this produces an invalid link with the following error message:

Sorry

This email address isn't associated with an active Google Calendar account: en.christian.holiday@group.v.calendar.google.com. Please check the email address and try again.

Even if I try escaping the @ sign with %40 (https://calendar.google.com/calendar?cid=en.christian.holiday%40group.v.calendar.google.com), I get the same error message.

How do I get my calendar's cid so that others can add it with a single click on a link?

Best Answer

Update:

Normally you can just append your calendar id to the url:

  • https://calendar.google.com/calendar?cid=ht3jlfaac5lfd6263ulfh4tql8@group.calendar.google.com

However, there are times when this doesn't work and you're required to use base64 encoding:

  • https://calendar.google.com/calendar?cid=ZW4udXNhI2hvbGlkYXlAZ3JvdXAudi5jYWxlbmRhci5nb29nbGUuY29t

The exact rules for when one will work and the other won't seem fuzzy to me. This is a few things I found:

  • If the id contains a #, unencoded id won't work, base64 will.
  • If the id is a resource (e.g. @resource.calendar.google.com), unencoded id works, base64 doesn't work.
  • If the id is a standard group (e.g. @group.calendar.google.com), both unencoded and base64 work.
  • If the id is a user's email address (e.g. @example.com), both unencoded and base64 work.
  • If the id is a group.v (e.g. @group.v.calendar.google.com), not sure which one will work as I've only seen these with the # symbol which forces you to use base64.

To create a single-click add to calendar link (if you are the calendar owner):

  1. Go to Calendar Settings.
  2. Under "Access permissions," click the "Get Shareable Link" button.
  3. It will be of the form https://calendar.google.com/calendar?cid=bWFya2V0aW5nQHbWFya2V0aW5nQH.
  4. Tapping on this link will prompt the user to add it to their Google Calendar.

To create a single-click add to calendar link (if you are not the calendar owner):

  1. Get the "Calendar ID."
  2. Encode it as base64 (e.g. by using a website such as base64encode.org).
  3. You now have the cid in a format that is expected by Google Calendar.
  4. Prepend https://calendar.google.com/calendar?cid= to the cid, and voila, you have a single-click add to calendar link.

    (Interestingly enough, the cid url will only work for a base64 encoded parameter even though the UI will show the unencoded email address in the error message.)

To verify that the link works, assuming you don't want to remove the calendar:

  1. Hide the calendar in Google Calendar by unchecking it on the left sidebar.
  2. Navigate to the link you just created.
  3. It should now be checked on the left sidebar.

Note: an alternative to figuring out the encoded cid, is to figure out where the +Google Calendar button (as part of option 1 in the question) takes you (e.g., via monitoring the network, or turning off your network and clicking the link).