fix: narrow default OAuth scopes to avoid restricted_client, improve non-interactive setup UX#30
Conversation
…ll flag, improve non-interactive setup UX Fixes googleworkspace#24, googleworkspace#25 - DEFAULT_SCOPES now aliases MINIMAL_SCOPES (no pubsub/cloud-platform) which avoids Google's restricted_client 403 on unverified OAuth apps - Add FULL_SCOPES and --full flag for users who need the broader set - Replace cryptic 'run setup interactively' error with step-by-step manual OAuth console instructions including URLs, options A/B/C
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience for the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🦋 Changeset detectedLatest commit: 4630e73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Code Review
This pull request introduces two significant user experience improvements. First, it narrows the default OAuth scopes to prevent restricted_client errors for users with unverified apps, which is a thoughtful change for first-time users. Second, it replaces a cryptic error in non-interactive environments with clear, actionable instructions for manual setup. The implementation is solid, and my feedback focuses on enhancing the maintainability of the newly added instructional text.
Address Gemini review (PR googleworkspace#30): replace hard-to-read backslash line continuations in large format! macros with concat! for clearer structure: - manual_oauth_instructions(): full step-by-step guide - stage_configure_oauth() wizard show_message: interactive prompt text No functional change; output text is identical.
🤖 Bot triage updateFixed in commit 4630e73Addressed Gemini review comments (setup.rs:1226, setup.rs:1264): Refactored both large
No functional change; output text content is identical, only indentation style was normalized. CI status: Only Pre-existing clippy failures on |
Review comments addressed ✅Both Gemini code review suggestions for readability were applied in commit Changes made:
Quality checks:
|
|
/gemini review |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
jpoehnelt
left a comment
There was a problem hiding this comment.
Good approach — narrowing the default OAuth scopes eliminates restricted_client errors for unverified apps, which is one of the most common first-run friction points.
A few notes:
-
--fullflag discoverability — the new flag only appears in the usage string printed byhandle_auth_command. Consider whether it should be surfaced ingws auth login --helpoutput more prominently, since users hitting scope errors might not know to look there. -
MINIMAL_SCOPESvsDEFAULT_SCOPESaliasing — havingDEFAULT_SCOPES = MINIMAL_SCOPESas a type alias is clean for future divergence, but the rustdoc comment onDEFAULT_SCOPEScould be more explicit that these are intentionally identical for now (rather than an accidental duplication). -
manual_oauth_instructionsURL injection —project_idis user-supplied and gets interpolated directly into URLs. The code path reaches here fromctx.project_id, which should already be validated by the setup flow, but sinceGwsError::Validationsurfaces this string to the user as an error message, confirm there's no XSS/injection risk in terminal emulators that interpret escape codes in URL strings. -
Non-interactive error recovery — the expanded
manual_oauth_instructionserror message is a significant UX improvement over "Please run setup interactively." Worth adding a test thatstage_configure_oauthwithctx.interactive = falseproduces an error message containing the consent URL. -
Scope consistency —
FULL_SCOPESstill includesdrive,gmail.modify, etc. which are inMINIMAL_SCOPES. This is intentional (a single list works fine for--full), but it's worth a comment noting thatFULL_SCOPESis a superset that adds cloud-platform/pubsub on top of the minimal set.
LGTM — the change is backward compatible and the --full escape hatch is the right design.
|
Follow-up on Gemini formatting comments in |
jpoehnelt
left a comment
There was a problem hiding this comment.
Thanks for the updates! LGTM.
…non-interactive setup UX (googleworkspace#30) * fix: narrow default OAuth scopes to avoid restricted_client, add --full flag, improve non-interactive setup UX Fixes googleworkspace#24, googleworkspace#25 - DEFAULT_SCOPES now aliases MINIMAL_SCOPES (no pubsub/cloud-platform) which avoids Google's restricted_client 403 on unverified OAuth apps - Add FULL_SCOPES and --full flag for users who need the broader set - Replace cryptic 'run setup interactively' error with step-by-step manual OAuth console instructions including URLs, options A/B/C * chore: add changeset * chore: cargo fmt * fix: refactor format! with backslash continuations to concat! macro Address Gemini review (PR googleworkspace#30): replace hard-to-read backslash line continuations in large format! macros with concat! for clearer structure: - manual_oauth_instructions(): full step-by-step guide - stage_configure_oauth() wizard show_message: interactive prompt text No functional change; output text is identical.
Summary
Fixes two first-run friction points that cause confusing failures for users with unverified OAuth apps.
Fixes #25 —
Error 403: restricted_clienton first loginThe old
DEFAULT_SCOPESincludedpubsubandcloud-platform, which Google marks as restricted and blocks for unverified apps. These scopes require app verification or Workspace domain admin approval.Changes:
DEFAULT_SCOPESnow aliasesMINIMAL_SCOPES— only core Workspace APIs (Drive, Gmail, Calendar, Sheets, Docs, Slides, Tasks) that never trigger the restricted-client blockFULL_SCOPESwith the broader set includingpubsub+cloud-platform--fullflag togws auth loginto opt in to full scopes (with a help note warning about the verification requirement)Fixes #24 — Cryptic "run setup interactively" error with no guidance
Non-interactive environments (CI, SSH sessions, scripts) would hit a dead-end error:
Cannot automate OAuth client creation. Please run setup interactively.with no actionable next steps.Changes:
manual_oauth_instructions()that builds a full step-by-step checklist with direct Cloud Console URLs scoped to the projectTesting
gws auth loginwith a fresh unverified app no longer triggersrestricted_clientgws auth login --fullrequests the full scope setgws auth setupin non-interactive mode returns the new detailed instructionsChangeset
.changeset/9df09438f1eb.md— patch