Repository navigation
feat(sources): connect Google Drive by signing in with Google - #404
Closed
adeelahmad wants to merge 1 commit into
Closed
adeelahmad wants to merge 1 commit into
adeelahmad wants to merge 1 commit into
Conversation
adeelahmad
force-pushed
the
claude/project-thread-kkr74u
branch
from
October 15, 2026 12:10
9fa99de to
a9c3218
Compare
Google Drive connections no longer need rclone run on another computer and a token pasted back. Sign in with Google opens Google's consent page in a small window; when it comes back the connection is made, tested and named after the account, and the dialog goes on to pick a folder whose files Lens imports. It uses the admin's own Google app, the one people can sign in to Lens with (login_provider google), through the same external_flow rows and callback, so nothing more is registered at Google and signing in to Lens can stay off. The app can be set up from the Drive dialog. Tokens are sealed as the source's token in rclone's shape, and rclone gets that app's client id and secret to renew them. POST /sources/signin hands agents a link for their person (not tied to a browser when started from an API token); source_oauth.fresh_token gives code that calls Google itself a working access token. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C
adeelahmad
force-pushed
the
claude/project-thread-kkr74u
branch
from
October 15, 2026 12:17
a9c3218 to
f4dab72
Compare
Owner
Author
|
Closing as superseded. #407 adds the shared Connect with Google flow ( The rest of this branch ships separately as smaller PRs:
Generated by Claude Code |
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: connecting Google Drive with a Google account meant installing rclone on another computer, running
rclone authorize drive, and pasting the JSON it printed into Lens.After: Sensors › Add connection › Google Drive › Google account has Sign in with Google. Google's consent page opens in a small window; when it comes back the connection is made, tested and named after the account ("Google Drive · you@gmail.com"), and the dialog goes straight on to picking a folder whose files Lens imports (the existing watch flow). A connection whose sign-in ran out shows Sign in again.
It uses the admin's own Google app, the same one people can sign in to Lens with (Settings › Sign-in,
login_provider:google), and the same callback (/api/v1/auth/external/google/callback), so nothing extra is registered at Google. If no Google app exists, the Drive dialog asks for its client ID and secret once, shows the redirect URI, and saves it with signing in to Lens left off. Pasting an rclone token and service accounts (#266) work as before.How: a new
source_oauth.pyadds amode: "source"flow to the existingexternal_flowrows (PKCE, ten minutes, used once, tied to the browser by the same cookie). The callback swaps the code (askingaccess_type=offline,prompt=consent), keeps the token sealed as the source'stokenin rclone's JSON shape, and recordsoauth: {provider, email}on the source;sources._confighands rclone that app'sclient_id/client_secret, because Google renews a token only for the app that issued it. A pasted token or a service account key dropsoauth. The popup reports back over a same-siteBroadcastChannelfrom a new public/connectedpage; where popups are blocked the whole page goes and comes back with?connected=<id>.Agents:
POST /api/v1/sources/signin {type: "drive", params}(or{source: id}) returns{url}. Started from an API token it isn't tied to a browser, so an agent can hand the link to its person; it works once within ten minutes and ends on/connected.source_oauth.fresh_token(db, cfg, src)gives code that calls Google directly (the Gmail thread) a renewed access token.Motivation and Context
Adeel asked for Google Drive "both oauth and via service account, with optional root folder, files get imported in Lens". Service accounts, the root folder ID and watched-folder import already existed; the OAuth path was the gap.
Types of changes
!in the title)Checklist:
tests/api/test_source_signin.py(5, against the fake OIDC provider, now with refresh tokens),__tests__/drive-signin.test.tsx(3),sources-model.test.ts. Full backend suite 1088 passed; jest 870 passed.docs/accordingly (processing.md Storage sources, authentication.md;mkdocs build --strictclean).## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
POST /sources/signinreturns a link an agent can hand to its person;POST /watchesthen imports.storage_source.oauth) that existing rows simply lack.make openapi).🤖 Generated with Claude Code
https://claude.ai/code/session_01VrczAC5nKz1zkCUvRKXG5C
Generated by Claude Code