fix(google-workspace): request minimal effective OAuth scopes (10 not 26)#421
Closed
JonasJesus42 wants to merge 1 commit into
Closed
fix(google-workspace): request minimal effective OAuth scopes (10 not 26)#421JonasJesus42 wants to merge 1 commit into
JonasJesus42 wants to merge 1 commit into
Conversation
…t 26)
Live testing returned "The caller does not have permission" on Calendar,
Gmail, Drive and People while Chat worked partially. The most likely
cause is that the OAuth client in Google Cloud Console didn't have the
26-scope union from the PRM `scopes_supported` arrays pre-approved on
its consent screen — Google silently drops any requested scope that
isn't declared on the client, so users got a token covering only the
subset that happened to be configured.
Replace the union with a hand-curated list of the broadest sensible
scope per service. Google's scope hierarchy means the broader scope
implicitly grants the narrower ones, so this still satisfies every
tool we proxy:
- calendar (full) → covers .readonly / .events / etc.
- chat.spaces, chat.messages,
chat.memberships → orthogonal, .readonly are subsets
- drive (full) → covers .readonly / .file
- gmail.modify + gmail.compose → read+label+drafts, no restricted scope
- contacts.readonly,
directory.readonly,
userinfo.profile → orthogonal People scopes
Side benefits beyond the bug fix: shorter consent screen, less likely to
hit Google's verification process for "restricted" scopes (we now avoid
mail.google.com/), and clearer least-privilege story.
If Google adds a tool needing a scope not on this list, extend the array
for the relevant service. The list is hand-curated and not regenerated by
`bun run generate-tools`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
Superseded by the workspace rewrite to bundle our REST-based Google MCPs (Calendar/Gmail/Drive/Docs/Sheets/Slides/Forms/Meet). The minimal-scopes change is moot once we no longer proxy Google's official MCPs from the workspace. |
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.
Symptom
Live testing returned "The caller does not have permission" on Calendar / Gmail / Drive / People, while Chat worked partially ("Requested entity was not found" — meaning the API authorized the call but found no data).
Root cause
The previous version asked for the union of every scope in each backend's PRM
scopes_supported— 26 scopes total. Google's OAuth flow silently drops any requested scope that isn't pre-declared on the OAuth client's consent screen, so users were getting tokens covering only the subset that happened to be configured (chat-* in this case).Fix
Replace the auto-union with a hand-curated minimal-effective set. Google's scope hierarchy means the broadest scope per service implicitly grants the narrower ones, so this still satisfies every tool we proxy:
calendar— covers all.readonly/.events.*variantschat.spaces,chat.messages,chat.memberships(orthogonal)drive— covers.readonly/.filegmail.modify+gmail.compose— read + label + drafts; avoids the restrictedmail.google.com/contacts.readonly,directory.readonly,userinfo.profileSide benefits
mail.google.com/, which is "restricted" by Google and triggers their verification processStill required (operational)
The OAuth client in Google Cloud Console must have these 10 scopes added to the consent screen. If any are missing, Google still drops them silently and the same symptom returns. To diagnose:
The returned
scopestring is exactly what the user's token has. If it's missing entries from the list above, the consent screen needs those scopes added.Test plan
bun scripts/check.ts google-workspace— passescalendar_list_events { calendarId: "primary" }gmail_search_threads { query: "is:unread newer_than:1d" }drive_list_recent_files {}chat_search_conversations { displayName: "..." }people_get_user_profile {}🤖 Generated with Claude Code
Summary by cubic
Request a minimal set of 10 Google Workspace OAuth scopes instead of the prior 26-scope union. This fixes “The caller does not have permission” errors and shortens the consent screen.
Bug Fixes
mail.google.com/scope.Migration
Written for commit 1a597b8. Summary will update on new commits.