Skip to content

feat(sources): sign in to Dropbox, OneDrive and Drive through rclone on the server - #411

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-kkr74u
Oct 15, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-kkr74u

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Description

Before: connecting Dropbox, OneDrive or Google Drive as a Google account meant installing rclone on another computer, running rclone authorize dropbox there, and pasting the JSON it printed into Lens. A token that stopped working showed "Paste new token", and the whole round trip started again.

After: those connections have Sign in with Dropbox (or Microsoft, or Google). The service's page opens in a new tab, Lens runs rclone authorize on its own server, and you sign in and allow rclone. The service then sends the tab to http://127.0.0.1:53682/?state=…&code=…. On the machine Lens runs on, rclone receives that itself and the dialog carries on with nothing to paste. Anywhere else that page doesn't load, so you paste its address into the dialog, which fills it in as soon as it looks right. After that the connection is made and tested, OneDrive's own drive is filled in, and the dialog goes on to the test-and-name step. "Paste new token" is now "Sign in again". Pasting a token from rclone still works through "Paste a token from rclone instead".

How:

  • rclone_signin.py starts rclone authorize <type> [options] --auth-no-open-browser with a private config, reads the service's link, and keeps one sign-in at a time (rclone_signin:<id>, ten minutes).
  • The pasted address is forwarded only to rclone's own port, with only state, code and error, and only when the state is this sign-in's.
  • The token is claimed atomically, so a poll and a paste can't both make the connection. It is sealed like a pasted token, and rclone refreshes it with its own app.
  • Routes: POST /sources/rclone-signin, POST /sources/rclone-signin/{id}, DELETE /sources/rclone-signin/{id}.
  • rclone_signin is declared in the schema, because SurrealDB 3 refuses to SELECT from a table nobody has written to yet.

Motivation and Context

Adeel asked for Drive to connect "through OAuth and through a service account" as a sensor. This gives Drive OAuth with no Google Cloud app at all, and Dropbox and OneDrive get the same. Drive's Connect with Google, through the user's own app, joins #407's shared flow once that merges. It replaces part of the closed #404.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: Drive (and Dropbox and OneDrive) connect over OAuth with no app of your own. Merges on green CI.
  • Agents: an agent with a write token calls POST /sources/rclone-signin, hands its person url, then posts the address they paste back (tested in test_signing_in_again_and_agents). A read-only token gets 403.
  • Zero setup: the image already ships rclone 1.75.1, and there's nothing to install elsewhere. Without rclone, the API answers "rclone isn't installed on this machine".
  • Fewest clicks and keystrokes: one click, sign in at the service, and at most one paste, which submits itself. On the server itself there's no paste at all.
  • Configurable: n/a, there's no new setting.
  • Light: one short-lived rclone process, only while someone is signing in.
  • Private and secure: the token is sealed per source. The threat model has a new row for /sources/rclone-signin: rclone listens on 127.0.0.1:53682 for up to ten minutes, one sign-in at a time, and only the state, code and error from a matching address are passed to it. Admin only, and the action is audited as source.signin.
  • Cost: n/a, no model calls.
  • User decides: the person signs in and consents at the service. Existing connections and their tokens are unchanged.
  • Upgrades: a new table, created idempotently at startup (DEFINE TABLE IF NOT EXISTS). Stored sources keep the same shape.
  • Honest: the docs describe only what's built, including that the service's page asks to allow rclone, not Lens.
  • Tests, docs and generated files updated: test_rclone_signin.py runs 6 tests against a stand-in rclone authorize, rclone-signin.test.tsx adds 4, and the model tests are updated. Also updated docs/processing.md and the CHANGELOG, and regenerated the client with make openapi. Locally the full backend suite passed (1097) on the branch before the rebase, and all 890 frontend tests passed after it.
  • Open standards; dependencies keep Lens MIT: OAuth 2.0 through rclone (MIT), with no new dependencies.
  • Result reported with evidence. Refine later: Drive on Connect with Google through the user's own app (after feat(sources): Connect with Google for Google Calendar connections #407), OneDrive through a Microsoft app, and a Drive folder picker.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C


Generated by Claude Code

…on the server

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C
@adeelahmad
adeelahmad merged commit 63beef1 into main Oct 15, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-kkr74u branch October 15, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants