Skip to content

feat(sources): connect Google Drive with Connect with Google - #417

Merged
adeelahmad merged 2 commits into
mainfrom
claude/project-thread-kkr74u
Oct 15, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/project-thread-kkr74u

Conversation

@adeelahmad

@adeelahmad adeelahmad commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Description

Before: a Google Drive connection could sign in as a Google account only through rclone (signing in on the server, or pasting a token from rclone authorize), or as a service account.

After: when Lens has a Google OAuth client (the Google sign-in provider's, or an earlier Google connection's), a new Drive connection's Google account option is Connect with Google. One click saves the connection and opens Google's consent screen. Google then sends you back to Sources with the account connected, and the connection shows "as mara@…". Read only asks Google for drive.readonly; Full access asks for all of Drive.

With no client, Drive signs in through rclone as before. Connect through your own Google app instead takes a client ID and secret and shows the redirect URI to register. Either way, the other route is one link away. A Drive connection whose sign-in stopped working shows Connect Google account on its row.

How: Drive joins #407's shared Connect with Google flow through a new gdrive.py (SCOPES(params) and keep). rclone keeps a Google account as its own token JSON and renews it with the client in its config. So the source keeps rclone's token shape, the client's id as a parameter (client_id), and its secret sealed (client_secret); the connected address is account, which is never passed to rclone. A token that comes from rclone (signed in through rclone, or pasted) renews with rclone's own client, so sources.update drops a client left over from before.

Motivation and Context

Adeel asked for Drive as a sensor through OAuth and a service account, with an optional root folder (#410 and #411 shipped the root-folder link and the rclone sign-in). This brings Drive onto the same one-click Google flow as Calendar and Gmail.

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 (ruff, prettier, eslint, tsc clean).
  • I added or updated tests:
    • tests/api/test_drive_google.py runs against the fake Google. It covers the rclone config Drive gets (token shape, client, parsed root folder, no account), full scope, and how a token from rclone drops the client.
    • __tests__/drive-google.test.tsx covers the one-click connect, the rclone default with no client, your own app, connecting again, and the model.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/processing.md, Storage sources).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: Drive by OAuth is one click when Lens has a Google client. Merging on green.
  • Agents: an agent creates the source and signs in through rclone (POST /sources/rclone-signin), or saves a token through the API. The consent step itself is a person's, as in feat(sources): Connect with Google for Google Calendar connections #407.
  • Zero setup: nothing to install. With Google sign-in set up there is nothing to enter.
  • Fewest clicks: one click to Google and one Allow.
  • Configurable: the client comes from Settings › Sign-in or the form. Nothing was added to the wizard.
  • Light: a few HTTPS calls.
  • Private and secure: this reuses feat(sources): Connect with Google for Google Calendar connections #407's admin-only, PKCE, single-use-state flow. The token and client secret are sealed. The token is kept only when the scope asked for was granted. The threat model's Connect with Google row now covers Drive's scopes and its sealed client secret.
  • Cost: no model calls. The code exchange is a google.token row in the activity ledger.
  • User decides: nothing connects until an admin clicks and consents. Existing Drive connections keep signing in as they did. Connect with Google is offered first for a new connection only when the admin already set up a Google client.
  • Upgrades: n/a. Stored data keeps its shape: client_id and account default to empty, and an old source without them behaves as before.
  • Honest: the docs say which client is used and when the client is dropped.
  • Tests, docs and generated files updated (openapi-check clean).
  • Open: OAuth 2.0, PKCE, OpenID Connect id token. No new dependencies.
  • Reported: the result goes back in the thread. Refine later: a Drive folder picker after connecting; rename a new connection to include the account; OneDrive through a Microsoft app of your own.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C

Base automatically changed from claude/project-thread-4kmlnn to main October 15, 2026 14:25
@adeelahmad
adeelahmad force-pushed the claude/project-thread-kkr74u branch 3 times, most recently from 8fc7015 to 0e438aa Compare October 15, 2026 15:02
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C
@adeelahmad
adeelahmad force-pushed the claude/project-thread-kkr74u branch from 0e438aa to b9f0c4a Compare October 15, 2026 15:15
Drive's Google account mode connects through Lens's Google client in one
click when it has one, shows the account it is connected as, and keeps
rclone and a Google app of your own a click away. Docs, changelog and
threat model follow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C
@adeelahmad
adeelahmad force-pushed the claude/project-thread-kkr74u branch from b9f0c4a to 0ad789c Compare October 15, 2026 15:15
@adeelahmad
adeelahmad merged commit d1e2413 into main Oct 15, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-kkr74u branch October 15, 2026 15:31
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