Katlendar Developer manual GitHub

Integrations

How katlendar is registered with Microsoft and Google, and how it reaches Proton, Nextcloud and Todoist.

The sync code for each service is in src/sync/. Sync explains how they fit together.

Signing in through the browser#

src/sync/oauth.rs signs in as RFC 8252 describes for programs on a person's own computer:

  • the sign-in page opens in the browser;
  • its answer comes back to a port on this computer that listens only for that one answer, on 127.0.0.1 with a port the system picks;
  • a fresh secret per sign-in (PKCE) ties the answer to this program.

The access token is held in memory only. The refresh token goes to the keyring (see Secrets).

Microsoft 365 and Outlook.com#

src/sync/graph.rs, through Microsoft Graph.

katlendar has its own app registration in Microsoft Entra. Its ID is graph::CLIENT_ID, 7d77eefe-6ef2-4727-8915-fadd4c44d9b8. It is:

  • a public client, with no secret;
  • open to any account type: work, school and personal;
  • set up with the redirect http://localhost (Microsoft takes any port with it) and the permission Calendars.ReadWrite.

The sign-in uses the common tenant, the scope Calendars.ReadWrite offline_access, and a login_hint with the address the person typed. Everything is read again every 30 days, so repeating events reach further ahead.

Bringing your own registration#

Someone can type their own client ID in the form that adds a Microsoft account. graph::client_id(own) prefers it to the built-in one. The guide explains this under "Use your own app registration", a heading the app links to.

What the registration needs from the site#

  • https://katlendar.date/.well-known/microsoft-identity-association.json names the app's ID. It is in the site's public/.well-known/, and public/_headers serves it as JSON. Microsoft reads it to show katlendar.date as the publisher's domain.
  • The registration's branding links to the privacy statement and the terms on katlendar.date.

If the client ID ever changes, change it in both places: graph::CLIENT_ID and the .well-known file.

Google Calendar#

src/sync/google.rs, through Google's CalDAV address, https://apidata.googleusercontent.com/caldav/v2/<email>/user.

katlendar ships no registration with Google. The person makes a project in Google Cloud and pastes its client JSON; from_client_json reads the ID and secret out of it. The guide's Google Calendar page walks through this.

  • The scope is https://www.googleapis.com/auth/calendar. Google's CalDAV takes nothing narrower.
  • The sign-in asks for access_type=offline and prompt=consent, so Google always hands back a refresh token.
  • Signing out calls google::revoke, so the token stops working at Google too.
  • While a project is in Testing mode, Google ends its sign-ins after 7 days. Publishing the project to production fixes that.

A Google client secret for an installed program isn't really secret, but Google still wants it sent. google::pack keeps it in the keyring beside the refresh token.

Proton#

src/sync/proton.rs, proton_srp.rs and proton_keys.rs. This is unofficial. Proton publishes no calendar API for other programs. The code follows what Proton's own open-source clients do (WebClients, go-proton-api, go-srp).

  • It talks to https://mail.proton.me/api.
  • It signs in with SRP, ported from go-srp (MIT), and asks for the second factor when the account has one.
  • Events are end-to-end encrypted. The password opens the account's keys, those open each calendar's key, and that opens the events. The pgp crate does the decryption.
  • The password itself is never kept.
  • It names itself to Proton as Other. KATLENDAR_PROTON_APPVERSION sets another name, should Proton start refusing that one.

Because the API isn't public, Proton can change it without notice. The live check covers Proton end to end; run it after any change here (see Testing).

When Proton answers with error 9001, it wants a check that the person is human. The app can't show that check, so it asks them to sign out and sign in again.

Nextcloud#

src/sync/nextcloud.rs. Nextcloud is reached over CalDAV, with a sign-in through the browser ("Login Flow v2"). The person signs in on the server's own page, and the server hands katlendar an app password of its own. The main password is never seen.

Todoist#

src/sync/todoist.rs, through Todoist's API v1 with the person's own API token. Each project is a task list. Tasks are read through the Sync endpoint, which hands back only what changed since the last read, and written as commands to the same endpoint.

CalDAV and subscriptions#

Any other CalDAV server works with an address, a user name and a password (src/sync/caldav.rs). A calendar link (.ics) can be subscribed to, read only; the app reads it again from time to time (src/syncing/run.rs).

Trademarks#

katlendar is not made by, affiliated with or supported by any of these services. The Todoist settings say so in the app. Check a service's terms before adding one.

Improve this page on GitHub