Skip to content

fix: keep automatic reauthorization from stopping at a Google Ads passkey prompt - #1353

Merged
steipete merged 2 commits into
mainfrom
fix/reauth-skip-ads-scope
Nov 25, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/reauth-skip-ads-scope

Conversation

@steipete

Copy link
Copy Markdown
Collaborator

Related: #1260

What Problem This Solves

People whose Google account was authorized before Google Ads became an explicit opt-in (#1260) still have the Ads (adwords) scope in their stored grant. When that refresh token expires, gog's automatic reauthorization replays every stored scope, including Ads. Google can require passkey enrollment before it grants Ads access, so an ordinary Gmail or Calendar command ends up on a "Create a passkey to continue" page and cannot reauthorize at all.

User Impact

Automatic reauthorization now leaves out a stored Ads scope unless the command that triggered it actually needs Ads. Gmail, Calendar, Drive, and other reauths complete without a passkey prompt. When Ads is dropped, gog says so on stderr and prints the command to restore it: gog auth add <email> --services user,ads --force-consent. Accounts that run Ads commands keep the Ads scope.

Why This Change Was Made

Reauth deliberately replays the stored scope set so a narrow command cannot silently shrink a broad grant. Ads is the exception, because requesting it now blocks the whole consent screen. When Ads is dropped, the request also stops asking Google to include previously granted scopes; otherwise the old Ads grant would be merged back in.

Evidence

  • New regression test TestReauthReplaysStoredAdsScopeOnlyForAdsRequests: a Gmail-triggered reauth drops the stored Ads scope and service, disables granted-scope merging, and prints the opt-in hint. An Ads-triggered reauth keeps Ads. The test fails on main and passes with this change.
  • go test ./internal/googleauth/ ./internal/cmd/ and golangci-lint run ./internal/googleauth/... pass locally.
  • Live observation on a real consumer Google account, through gog's own gog auth add OAuth flow: a consent request that included adwords stopped at Google's passkey enrollment page. The same request without adwords reached the normal consent screen and completed. The automatic reauth path itself was covered by the unit test, not exercised live.

Google can require passkey enrollment before it grants the Ads (adwords) scope, which blocks the whole consent screen. Automatic reauthorization replayed every stored scope, so accounts first authorized before Ads became opt-in (#1260) kept hitting the passkey gate on unrelated Gmail or Calendar commands. Drop a stored Ads scope unless the failing request needs Ads, keep Google from merging the old grant back, and print how to opt in again.
@clawsweeper

clawsweeper Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T20:40:47.569818Z 7da1684 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 24, 2026
@clawsweeper

clawsweeper Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Automatic reauthorization removes stored Google Ads access for non-Ads requests and explains how to restore it.

Example: user@example.com has a revoked token containing Gmail and adwords scopes and runs a Gmail command.

  • Before: Recovery requests both scopes and can stop at Google's mandatory passkey enrollment page.
  • After: Recovery requests Gmail without Ads or incremental grant merging and prints the Ads opt-in command.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and regression coverage support correctness, but supplied execution evidence does not establish the changed recovery and existing-state persistence behavior.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An ordinary Gmail or Calendar command cannot recover an expired authorization because a legacy Ads grant triggers mandatory passkey enrollment.
Reason: The maintainer-authored change completes the established Ads opt-in direction and explains its intentional exception to stored-grant preservation.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a remaining automatic-reauthorization failure on current main, and its maintainer-authored direction is established; source review found no concrete introduced bug.

Priority: P2
Reviewed head: 18e11c0b5ef64a1c97d1f7d1a79706894d274637

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted terminal output or a recording of automatic recovery from a v0.48.1 stored Ads grant through consent, persistence, and successful command retry, including retained non-Ads access and an Ads-triggered recovery that keeps Ads.
Agent review details

How this fits together

The shared OAuth recovery function receives the triggering command's requirements and stored token metadata, obtains browser consent, validates the account identity, and returns replacement metadata for persistence and request retry.

flowchart TD
A[Gmail or Ads command] --> B[Invalid grant recovery]
B --> C[Stored grant and request requirements]
C --> D[Shared reauthorization scope selection]
D --> E[Google browser consent]
E --> F[Identity validation]
F --> G[Persist replacement token and retry]
Loading

Technical review

Best possible solution:

Keep the narrow Ads exception in shared reauthorization while retaining other stored grants, identity checks, and persistence-before-retry behavior.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows that a non-Ads command replays a stored adwords scope; the author reports the associated Google passkey gate, but this review ran no target code.

Is this the best way to solve the issue?

The change fixes scope selection at its existing shared owner and prevents incremental authorization from restoring the removed Ads grant, without adding another recovery path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 31c4e14186e8.

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 229da12 adds internal/googleauth/reauth.go:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 229da12809c1; files: internal/googleauth/reauth.go)
  • higginz777: Raw commit c1a4191 adds internal/googleauth/reauth.go:161 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: c1a41914a833; files: internal/googleauth/reauth.go)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: The failure blocks interactive recovery for existing accounts carrying Ads grants, with impact limited to that authorization state.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: The failure blocks interactive recovery for existing accounts carrying Ads grants, with impact limited to that authorization state.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the automatic-recovery and existing-token upgrade evidence described in the proof assessment.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 24, 2026, 3:52 PM ET / 20:52 UTC.

@steipete

Copy link
Copy Markdown
Collaborator Author

Stored-token compatibility proof for the "existing stored data" item. The persisted token format is unchanged; this run shows that tokens written by an older release, including ones that still carry the Ads scope, load and work with this branch.

I built the PR head (18e11c0b, v0.48.2-0.20261124203958-18e11c0b5ef6) and ran it against a real file keyring whose tokens were written by gog v0.47.0. Account names are redacted.

--- auth list --check
workspace-account-A valid=true stored_adwords=true  services=7  scopes=46
workspace-account-B valid=true stored_adwords=true  services=1  scopes=32
consumer-account-C  valid=true stored_adwords=false services=21 scopes=47
--- auth doctor --check
doctor: ok   (refresh-token exchange ok for all three accounts)
--- reads with account A (stored grant still includes adwords)
gmail search ok, results=1
calendar events ok

The new code only changes which scopes an automatic reauthorization requests. It does not affect loading or refreshing existing tokens, and the stored services/scopes fields keep their names and shape.

Gap: the automatic-recovery path for a revoked token that carries Ads is covered by TestReauthReplaysStoredAdsScopeOnlyForAdsRequests (Gmail-triggered: Ads dropped, include-granted-scopes off, hint printed; Ads-triggered: Ads kept). It was not exercised live, because that would mean revoking a working account's grant. The live consent behavior is the observation in the PR body: with adwords, Google stops at passkey enrollment; without it, consent completes.

@steipete
steipete merged commit cfee066 into main Nov 25, 2026
18 checks passed
@steipete
steipete deleted the fix/reauth-skip-ads-scope branch November 25, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant