Subscribing to external ical programmatically - google-api

Through the Google Calendar UI a user can add an external iCAL calendar to their CalendarList.
When that Calendar is retrieved through CalendarList, the Calendar URL is not included. Additionally, it doesn't appear that it's possible to add an external iCal Calendar to a user's CalendarList.
Is this the case? Is there a way of programmatically subscribing a Google Calendar user to an external iCal feed?
Internally the Calendar UI uses the following URL to add an external calendar:
https://calendar.google.com/calendar/addcalendarfromurl
This URL takes the the following parameters by either POST or GET:
curl: calendar url (url encoded).
cimp: UI sets this to true, not sure what it does.
cpub: true|false - make calendar public
secid: security id from the client (session Id perhaps). Not specifying this brings a 403 error.
If the user isn't logged into the Calendar they will be redirected to the Google Login screen. If I had a way of generating a secid (perhaps OAUTH?), I could add a link to allow the user to add the calendar automatically.

Unfortunately there doesn't seem to be any updates on Google Calendar API having an import .ics feature. A ticket has been logged since 2007 and still doesn't have any resolution as of this moment.
The only option I can find is to manually import the .ics file in the user's Google Calendar web UI. The Import events to Google Calendar support page discusses the issue.
Step 2: Import events into Google Calendar
After you've exported your events, you can import them into Google Calendar.
Open Google Calendar on a computer. Note: You can only import from a computer, not a phone or tablet.
In the top right, click Settings settings gear button > Settings.
Open the Calendars tab.
Click Import calendars between the "My calendars" and "Other Calendars" sections.
Click Choose File and select the file you exported. The file should end in "ics" or "csv"
Choose which calendar to add the imported events to. By default, events will be imported into your primary calendar.
Click Import.
If you're using a ZIP file, find it on your computer and open it. You'll see ICS files for each of your calendars. Take the individual files out of the ZIP file, and import each ICS file individually.
Note: Repeating events might not show up that way if you import them from a CSV file, but they'll be on your calendar as a series of one-time events.

Related

Edit Google Calendar "From" and "Organizer"

I want to create event via google calendar api using Go. I found out that the sender (From) is whoever responsible in client_id I provide in the google API, in this case me. Can I edit this sender, so that it is not sent from me? At least I can edit the display name of the sender, the email I think will always be my email
Also about editing the organizer, I tried to use move action but it only moves the event, not change the organizer. Is there other way to edit organizer?
To address your questions:
1. Can I create an event from another address?
What you want can be done by creating a service account and performing domain-wide-delegation
What is a service account?
A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs - in your situation the Calendar API.
After creating the above mentioned service account, you will have to perform domain-wide-delegation and impersonate a user in your domain in order to be able to create the event wanted.
Now, when writing the code for your application, you will have the use the credentials that were created for this account in order to authorize the requests.
OR
If you want to specifically edit only the display name of the creator of the event, you can perform an update request:
PUT https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId
And add in the request body this:
"creator": {
"displayName": "UPDATED DISPLAY NAME"
}
2. Can I edit the organizer?
According to the Calendar API Documentation:
organizer > The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
Therefore, the organizer can be changed/updated only when importing the event in question.
Reference
Authorizing Requests to the Google Calendar API
;
Creating A Service Account;
Calendar API Events Resource;
Calendar API Events:Update.

Outlook - Copy group calendar events to user outlook calendar

We have a recurring event setup in Office 365 group calendar. If a new member is added to this group, that member can see the event in "Group" calendar and in order to see this event in main calendar, user have to click on "Copy to My calendar" in group event.
Is there any way to do this via code/script? Basically achieve "Copy to My calendar" for Office 365 group calendar to User's main calendar via code.
I'm not sure when you click "Copy to my calendar" if it has some smart link or if it is just a copy at a point in time.
You could subscribe to the calendar using a webhook. That webhook would call your API hosted somewhere (an Azure Function, a web api hosted on Azure App Service). Your API would recieve the event id, it could then fetch the full details of the event and then create a new event on the users calendar.
I'm assuming that you'd want this to create it on all users calendar and also to update it if there were changes on the source event.
Its complex for sure doing it this way.
https://learn.microsoft.com/en-us/graph/webhooks
https://learn.microsoft.com/en-us/graph/api/resources/event?view=graph-rest-1.0

Programmatically adding attendees to calendar event on macOS

Our requirement was to add an invitee to an EKEvent.
As written in the Apple EventKit documentation it is not allowed to add meeting invitees programmatically since those properties of an EKEvent are read-only.
We tried another way to create an .ics file and add it the calendar programtically. But with this approach we are not able to create attendees to an event hosted in an Exchange account. Where as other accounts like GMail are working fine.

Import .ics Feed Into Outlook "My Calendar"

This might not be the right place to ask this, but I am trying to automatically update an Outlook user's personal calendar with events from a site. Outlook's "Internet Calendar Subscription" adds the events from an .ics feed to a separate calendar (under "Other Calendars"). I can import the .ics manually via File -> Open -> Import -> Import an iCalendar (.ics) or vCalendar file (.vcs) -> "Import items into your calendar" How do I import an .ics feed into the personal calendar automatically?
You cannot 'import' automatically - that is entirely a user action.
If the user decides to 'subscribe' to the calendar, then it will refresh automatically at whatever intervals the calendar application and the user specify.
Import:
a once off action, goes into the calendar specified by the user, usually the default or main calendar. (Some apps seem to make it a new calendar anyway- thunderbird?) No updates unless the user deletes and re-imports or modifies. Think of this as an aid to the user so they do not have to manually create the events in their calendar. They can modify these events themselves
Subscribe:
This maintains a separate calendar in the calendar application and is refreshed at intervals determined by the calendar application. Thus updates will be made. User cannot change these events. Usually the calendar app allows one to click calendars on/off. Has great use for saying keeping one's personal calendar and overlaying your partners calendar, the kids, the yoga club schedule, the countries public holidays, the school term calendar, phase of the moon or whatever takes the users fancy and being able to click these non main calendars off easily to see a clean uncluttered view.

Google Calendar API on add event callback for sync

I am using google-api-php-clientfor fetching and inserting Google Calendar events. Now I want to synchronize events on my system with events on Google Calendar.
I am wondering, if I add Event in Google Calendar, can it be automatically added in my system (maybe with some callback url) so I don't need to use CRON jobs to recheck events in Google Calendar in some time interval?
Thank you!
Google provides both iCal and XML output for viewing from external applications. This URL can be found by clicking on the drop down from your calendar name while logged in, selecting settings, and the calendar name. The private address row gives you both iCal and XML URLs.
Here are instructions for Outlook and iCal.

Resources