auth login --services: cloud-platform is re-added after being deselected in the scope picker

Open
#918 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #929 by @grep999 — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reproducing gws auth login --services gmail and inspect the auth login scope-picker flow that builds the authorize URL. Trace how picker state becomes the final scope list, then verify that deselecting cloud-platform and other scopes removes them from the URL while the selection counter remains accurate.

Written by the indexing model from the issue text.

Description

Version: gws 0.22.5 (@googleworkspace/cli via npm), node v20.11.1, Linux 6.8.0

auth login --services <svc> opens the scope picker. Scopes deselected in the picker can still end up in the authorize URL. cloud-platform is preselected and is re-added regardless of the selection.

Repro
  1. gws auth login --services gmail
  2. In the picker, deselect everything except gmail.send. Header reads Select OAuth scopes 1/17 selected.
  3. Enter.
  4. Read the printed authorize URL.

scope= contains:

https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/cloud-platform          <- deselected at step 2
openid
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

Expected: no cloud-platform.

--scopes is unaffected and produces exactly what is asked for:

$ gws auth login --scopes https://www.googleapis.com/auth/gmail.send
scope=https://www.googleapis.com/auth/gmail.send openid \
      https://www.googleapis.com/auth/userinfo.email \
      https://www.googleapis.com/auth/userinfo.profile
Impact

cloud-platform grants read, write and delete across the user's Google Cloud resources. Someone who opens the picker to narrow scopes, sees 1/17 selected, and consents, grants it anyway. The counter reports the intended selection, so nothing on screen shows the grant is wider than chosen. The authorize URL is the only place the real scope list appears, and it is long enough to wrap in a terminal.

gmail.readonly (restricted, full mailbox read) is also preselected via the Recommended (Core Consumer Scopes) entry.

Also

Toggling Recommended (Core Consumer Scopes) off moves the counter from 9/17 to 8/17 but leaves the eight individual scopes checked, cloud-platform among them. Each has to be deselected separately. If the row is meant to act as a group toggle, that is a second bug; if it is just another checkbox, the name reads like a group.

Suggested fix

Build the authorize URL from picker state, or print the resolved scope list for confirmation before opening the browser. The second is useful on its own: right now checking what you are about to grant means parsing a URL by eye.

Dominant language
Rust
Stars
32.3k
Forks
2k
Avg merge
16h 3m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleworkspace/cli

All issues in googleworkspace/cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.