<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zheng Jiawen</title>
    <description>The latest articles on DEV Community by Zheng Jiawen (@zheng_jiawen_a5fbf3742669).</description>
    <link>https://dev.to/zheng_jiawen_a5fbf3742669</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2643753%2F968ed48e-779d-413a-963a-d5f8dfeb5705.png</url>
      <title>DEV Community: Zheng Jiawen</title>
      <link>https://dev.to/zheng_jiawen_a5fbf3742669</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zheng_jiawen_a5fbf3742669"/>
    <language>en</language>
    <item>
      <title>How sync works in tatsu</title>
      <dc:creator>Zheng Jiawen</dc:creator>
      <pubDate>Sat, 10 Oct 2026 10:17:40 +0000</pubDate>
      <link>https://dev.to/zheng_jiawen_a5fbf3742669/how-sync-works-in-tatsu-3gd2</link>
      <guid>https://dev.to/zheng_jiawen_a5fbf3742669/how-sync-works-in-tatsu-3gd2</guid>
      <description>&lt;p&gt;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.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;provider&lt;/th&gt;
&lt;th&gt;method&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DAViCal&lt;/td&gt;
&lt;td&gt;basic auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baikal&lt;/td&gt;
&lt;td&gt;basic auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apple calendar&lt;/td&gt;
&lt;td&gt;basic auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Next cloud&lt;/td&gt;
&lt;td&gt;basic auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Google calendar&lt;/td&gt;
&lt;td&gt;Oauth&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Basic auth
&lt;/h3&gt;

&lt;p&gt;basic auth is pretty simple, you basically need 3 things; a server url, username, and password to access the external caldav server's endpoints. &lt;br&gt;
The implementation of such a sync is as follows: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;user inputs the server url, username, and password in a form.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tatsu's &lt;code&gt;/calDav/account&lt;/code&gt; api 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.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;note: Each user can only have one caldav account.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;tatsu's &lt;code&gt;/calDav/sync&lt;/code&gt; api 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.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Oauth
&lt;/h3&gt;

&lt;p&gt;Oauth implementation is more complex, but it is way more user friendly. currently only google calendars can be synced this way.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;when user clicks on the sync Google calendar button, authJs's &lt;code&gt;signIn&lt;/code&gt; function is called with &lt;code&gt;callback_url = tatsu.com/todo/sync?calendarSync=true&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;note: &lt;code&gt;callback_url&lt;/code&gt; is authjs's way of remembering where to redirect user after oauth.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;this signIn function obtains a &lt;code&gt;refresh_token&lt;/code&gt; from google servers, then determines if this is a syncing operation by looking at the &lt;code&gt;callback_url&lt;/code&gt;. It then stores this &lt;code&gt;refresh_token&lt;/code&gt; into the caldav accounts table if the google caldav server can be acessed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The google consent page then redirects user to tatsu's sync page &lt;code&gt;tatsu.com/todo/sync?calendarSync=true&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;tatsu's sync page detects the search parameter and calls the &lt;code&gt;/calDav/sync&lt;/code&gt; api which does the same thing as the basic auth scenario.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>sideprojects</category>
    </item>
  </channel>
</rss>
