accounting-agent

Google Sheets sync (direct API, no MCP)

sync-ledger.js mirrors ledger.csv into the Ledger tab of the Google Sheet “Ledger” (owned by @gmail.com). It authenticates with the OAuth client in `env.txt` and calls the Sheets API directly.

One-time setup

  1. In Google Cloud Console (the project where the env.txt OAuth client lives):
    • APIs & Services → Library → enable Google Sheets API.
    • If the OAuth client is a Web application type, add http://localhost:53682/ to its Authorized redirect URIs. (A Desktop app client needs no change.)
    • If the OAuth consent screen is in Testing mode, add <your-google-account>@gmail.com as a test user. Note: testing-mode refresh tokens expire after 7 days — publish the app to “In production” to avoid weekly re-authorization.
  2. Run node sync-ledger.js auth, open the printed URL, and sign in as **@gmail.com** (the sheet owner). This writes `token.json`.

Every run after

node sync-ledger.js

Clears the Ledger tab and rewrites it with the full contents of ledger.csv (header + all rows), so the sheet always matches the local ledger exactly. ledger.csv stays the source of truth; the sheet is a mirror.

Files — keep private

Do not commit either file if this folder ever becomes a git repository.