Skip to content

fix(auth): skip scope picker when gws auth login --services is provided#671

Open
hy0235 wants to merge 2 commits intogoogleworkspace:mainfrom
hy0235:fix/auth-login-services-reopen
Open

fix(auth): skip scope picker when gws auth login --services is provided#671
hy0235 wants to merge 2 commits intogoogleworkspace:mainfrom
hy0235:fix/auth-login-services-reopen

Conversation

@hy0235
Copy link
Copy Markdown

@hy0235 hy0235 commented Apr 4, 2026

Supersedes #645, which was auto-closed by the stale bot.

Description

Fixes #577.

This change makes gws auth login --services ... skip the interactive scope picker in default login mode and resolve scopes directly from the provided service filter.

It also improves service filtering so exact scope short names such as documents.readonly are accepted in addition to prefix-based matches.

Dry Run Output: Not applicable for this bug fix.

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

🦋 Changeset detected

Latest commit: fbb03c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 optimizes the authentication process for the CLI by bypassing the interactive scope selection when specific services are requested via the command line. It also enhances the flexibility of service filtering by allowing exact matches for scope short names, ensuring more precise scope resolution.

Highlights

  • Interactive Scope Picker: The interactive scope picker is now automatically skipped when a services filter is provided during login, streamlining the authentication flow.
  • Service Filtering: Improved the service filtering logic to support exact scope short name matches, such as 'documents.readonly', in addition to existing prefix-based matching.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the authentication logic to skip the interactive scope picker when a services filter is provided and allows the filter to match exact scope short names. The review feedback identifies a potential compatibility issue with the is_none_or method in older Rust versions and suggests passing the ScopeMode enum by reference to avoid moving ownership of non-Copy data.

services_filter: Option<&HashSet<String>>,
) -> bool {
matches!(scope_mode, ScopeMode::Default)
&& services_filter.is_none_or(|services| services.is_empty())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The use of Option::is_none_or was stabilized in Rust 1.82.0. If this project maintains a Minimum Supported Rust Version (MSRV) lower than 1.82, this will cause a compilation error. To ensure broader compatibility, consider using map_or(true, ...) or a simple match statement.

Suggested change
&& services_filter.is_none_or(|services| services.is_empty())
&& services_filter.as_ref().map_or(true, |services| services.is_empty())

Comment on lines +809 to +811
fn should_run_interactive_scope_picker(
scope_mode: ScopeMode,
services_filter: Option<&HashSet<String>>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The scope_mode parameter is passed by value, which moves the ScopeMode enum. Since ScopeMode contains a Vec<String> in its Custom variant, it does not implement Copy. While this works here because scope_mode is not used after the call in resolve_scopes, it is better practice to pass it by reference to avoid unnecessary moves and potential future use-after-move errors.

Suggested change
fn should_run_interactive_scope_picker(
scope_mode: ScopeMode,
services_filter: Option<&HashSet<String>>,
fn should_run_interactive_scope_picker(
scope_mode: &ScopeMode,
services_filter: Option<&HashSet<String>>,
) -> bool {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gws auth login ignores -s / --services

2 participants