Skip to content

fix: use documents scope to allow editing existing Google Docs#336

Open
levon003 wants to merge 1 commit into
onecli:mainfrom
levon003:fix/google-docs-documents-scope
Open

fix: use documents scope to allow editing existing Google Docs#336
levon003 wants to merge 1 commit into
onecli:mainfrom
levon003:fix/google-docs-documents-scope

Conversation

@levon003

@levon003 levon003 commented Jun 1, 2026

Copy link
Copy Markdown

Summary text below written by Opus 4.8, but I've carefully reviewed the text and agree with Opus that this is likely a change you want to incorporate.

Problem

The google-docs app requests drive.readonly + drive.file, which only permits editing documents the app itself created/opened. Editing a pre-existing Google Doc via documents.batchUpdate fails with 403 PERMISSION_DENIED, even when the connected account has edit rights on the file.

Fixes #335.

Fix

Mirror the Sheets fix in #319 and its follow-up scope tightening in #323 — replace the broad Drive scopes with resource-specific Docs scopes:

  • drive.readonlydocuments.readonly (read)
  • drive.filedocuments (read/write — allows editing any existing doc)

This matches the current google-sheets definition (spreadsheets.readonly + spreadsheets) and follows least privilege: the Docs app no longer requests read access to all Drive files — Drive listing/search remains the google-drive app's responsibility.

Verification

  • pnpm --filter @onecli/api check-types
  • pnpm --filter @onecli/api lint
  • prettier --check

Verified empirically against the live Docs API: the equivalent Sheets change (#319) took editing an existing spreadsheet from 403 to 200; Docs is the structurally identical provider.

Note for existing connections

Existing google-docs connections must be reconnected to pick up the new scope (consent re-prompt) — same as Sheets after #319.

The google-docs app requested drive.readonly + drive.file, which only
permits editing documents the app itself created. Editing a pre-existing
Google Doc (documents.batchUpdate) fails with 403 PERMISSION_DENIED even
when the connected account has edit rights.

Mirror the Sheets fix (onecli#319) and its follow-up scope tightening (onecli#323):
replace the Drive scopes with resource-specific Docs scopes.

- drive.readonly -> documents.readonly (read)
- drive.file     -> documents          (read/write existing docs)

Matches the current google-sheets definition and follows least privilege:
the Docs app no longer requests broad read of all Drive files; Drive
listing/search remains the google-drive app's responsibility.

Fixes onecli#335.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Google Docs permissions prevents editing existing files

1 participant