Skip to content

feat(auth): open the OAuth URL in the default browser - #894

Closed
sjawhar wants to merge 1 commit into
googleworkspace:mainfrom
sjawhar:feat/auth-login-open-browser
Closed

feat(auth): open the OAuth URL in the default browser#894
sjawhar wants to merge 1 commit into
googleworkspace:mainfrom
sjawhar:feat/auth-login-open-browser

Conversation

@sjawhar

@sjawhar sjawhar commented Aug 5, 2026

Copy link
Copy Markdown

Continues #888, which the staleness bot closed after 72 hours and which GitHub refuses to reopen (the API returns a validation error even though the head branch is intact at af57b34).

Everything from #888 carries over unchanged:

  • gws auth login opens the OAuth URL via $BROWSER, then the platform opener (xdg-open / open / explorer), spawned detached; the URL is always printed as a fallback. The login flow currently has no opener at all and ignores $BROWSER; feat(auth): open OAuth URL in default browser automatically #875, which added one, was also closed by the staleness bot rather than reviewed.
  • URL validation before spawning, per the Gemini feedback on feat(auth): open OAuth URL in default browser automatically #875.
  • The one review finding on feat(auth): open the OAuth URL in the default browser #888 (use thread::Builder::spawn so a failed reaper-thread spawn cannot panic the CLI) was addressed in af57b34; the follow-up Gemini pass had no further feedback.
  • Two riders, each justified in its own commit: a clippy fix in script.rs (unmodified main fails the workspace clippy gate on current stable) and a test-env leak fix in auth.rs (bare set_var leaked CONFIG_DIR between tests; now uses the existing EnvVarGuard).

Ready for human review.

gws auth login now attempts to open the authorization URL - $BROWSER first,
otherwise the platform opener - while keeping the printed URL as the
copy-paste fallback. Applies to both the proxy-aware flow and the yup-oauth2
flow delegate. Supersedes googleworkspace#875.

Also unbreaks CI on current stable (clippy 1.97 rejects a nested if in
helpers/script.rs on unmodified main) and fixes a 1-in-6 test flake
(a bare set_var leaked GOOGLE_WORKSPACE_CLI_CONFIG_DIR into later tests;
now uses the module's own EnvVarGuard).
@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: af57b34

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 Minor

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

@googleworkspace-bot googleworkspace-bot added area: auth area: core Core CLI parsing, commands, error handling, utilities labels Aug 5, 2026
@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 enhances the user experience for the CLI authentication flow by automatically launching the system's default browser to navigate to the OAuth URL. It includes necessary security safeguards for URL handling, ensures cross-platform compatibility, and addresses minor test isolation and code quality issues.

Highlights

  • Browser Integration: Implemented automatic opening of OAuth login URLs in the default system browser using platform-specific commands (xdg-open, open, explorer).
  • Security and Robustness: Added URL validation to prevent shell injection and ensured browser processes are spawned in a non-blocking, detached manner with a background reaper thread.
  • Test Improvements: Fixed a test environment leak in auth.rs by using EnvVarGuard and added comprehensive unit tests for browser command selection and URL sanitization.
  • Code Cleanup: Applied a clippy fix in script.rs to simplify pattern matching logic.
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 the 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 counterproductive. 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.

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

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.

Code Review

This pull request introduces the ability to automatically open OAuth login URLs in the default browser across Linux, macOS, and Windows, with a fallback to copy-pasting the URL. It also resolves an environment variable leakage issue in tests by utilizing EnvVarGuard, and simplifies a match expression in the script helper. No review comments were provided, so there is no additional feedback.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This PR has been inactive for 72 hours. Closing to keep the queue clean.

@github-actions github-actions Bot added the Stale label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 72 hours. Feel free to magically reopen it if you want to continue working on it!

@github-actions github-actions Bot closed this Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth area: core Core CLI parsing, commands, error handling, utilities Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants