this is a (internal) documentation of how syncing to cloud providers work in my todo app. Tatsu provides the option to sync to cadav servers via basic auth or Oauth.
| provider | method |
|---|---|
| DAViCal | basic auth |
| Baikal | basic auth |
| Apple calendar | basic auth |
| Next cloud | basic auth |
| Google calendar | Oauth |
Basic auth
basic auth is pretty simple, you basically need 3 things; a server url, username, and password to access the external caldav server's endpoints.
The implementation of such a sync is as follows:
user inputs the server url, username, and password in a form.
-
tatsu's
/calDav/accountapi is called with the three inputs, this api attempts to connect to the caldav server, and if succesful, stores the three values into tatsu's caldav accounts table.note: Each user can only have one caldav account.
tatsu's
/calDav/syncapi is then called, which connects to the caldav server using the credentials from tatsu's caldav account table, and performs syncing operation on calendar events.
Oauth
Oauth implementation is more complex, but it is way more user friendly. currently only google calendars can be synced this way.
-
when user clicks on the sync Google calendar button, authJs's
signInfunction is called withcallback_url = tatsu.com/todo/sync?calendarSync=truenote:
callback_urlis authjs's way of remembering where to redirect user after oauth. this signIn function obtains a
refresh_tokenfrom google servers, then determines if this is a syncing operation by looking at thecallback_url. It then stores thisrefresh_tokeninto the caldav accounts table if the google caldav server can be acessed.The google consent page then redirects user to tatsu's sync page
tatsu.com/todo/sync?calendarSync=truetatsu's sync page detects the search parameter and calls the
/calDav/syncapi which does the same thing as the basic auth scenario.
Top comments (0)