gws auth login can silently leave a stale/split token cache, causing 403 insufficient authentication scopes after re-auth
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
- #959 par @phatmandrake — fermée sans fusion
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- rust
- Domaine
- authentication, cli
Piste de recherche
Start by tracing the auth login flow and how ~/.config/gws/credentials.enc and ~/.config/gws/token_cache.json are read, written, and invalidated. Reproduce with gws auth login -s drive,docs, then verify that a fresh login clears or replaces both stores and that gws drive files list succeeds without insufficient authentication scopes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
After re-authenticating (gws auth login -s drive,docs), gws continued returning 403 insufficient authentication scopes on every Drive API call, while Gmail-scoped calls succeeded fine throughout. The login command's own output correctly listed https://www.googleapis.com/auth/drive as a granted scope, and ~/.config/gws/credentials.enc had a fresh timestamp — but the actual Drive API calls kept failing as if that scope had never been granted.
Environment
gwsversion: 0.11.1 (@googleworkspace/cli)- macOS 15.7.3 (Build 24G419)
- Auth method: OAuth2, installed/desktop client (
redirect_uris: ["http://localhost"]) - Keyring backend:
keyring
What was ruled out before finding the real cause
Extensive troubleshooting confirmed this was not caused by any of the following (each checked directly):
- OAuth consent screen scope configuration (Drive API confirmed
ENABLEDviagcloud services list) - OAuth consent screen test users list (account confirmed present)
- A stray local process holding a port from a previous
gws auth logininvocation (found and killed one, no change) - A full OS reboot (no change — rules out any in-memory/process-level caching)
client_secret.jsonvalidity (if this were invalid, login itself would fail withinvalid_client, not succeed and then fail on API calls — and other-scoped calls, e.g. Gmail, worked fine throughout)
Multiple full gws auth login -s drive,docs re-runs across this window, including after switching to a different Google account and back, did not resolve the issue.
Root cause (as best diagnosed)
~/.config/gws/ contains two separate local token/credential stores:
credentials.enc(encrypted, gets a fresh timestamp on everygws auth login)token_cache.json(binary — not actually JSON despite the extension/name; failed UTF-8 decode when inspected)
A normal gws auth login re-auth appears to refresh credentials.enc but not fully invalidate/replace whatever state token_cache.json holds (or vice versa — the exact read/write interaction between the two wasn't fully traced from the outside). The practical symptom: the CLI looks like it completed a fresh login with the requested scope, but the token actually used for API calls doesn't carry that scope.
Workaround that fixed it
Manually deleting the cached credential/token state (while preserving the app config) and then doing a completely fresh login resolved the issue immediately:
rm ~/.config/gws/credentials.enc ~/.config/gws/token_cache.json
rm -rf ~/.config/gws/cache/* # cached API discovery docs, unrelated to auth but safe to clear too
gws auth login -s drive,docs
(client_secret.json and .encryption_key were left untouched — those are the app identity/encryption key, not per-session state.)
Immediately after this, gws drive files list succeeded and returned real results.
Suggested fix
gws auth login (or a new --fresh/--clear-cache flag) should fully clear all local token/credential state before starting a new interactive login, rather than leaving a possibly-stale secondary cache (token_cache.json) in place alongside a freshly-written credentials.enc. Right now the only way to force a truly clean re-auth is to know to manually delete files inside ~/.config/gws/ — there's no documented or CLI-exposed way to do this.
Happy to provide more detail if useful — this took a couple hours of systematic elimination to track down, so hopefully this saves someone else the trouble.
- Langage dominant
- Rust
- Étoiles
- 32.3k
- Forks
- 2k
- Merge moyen
- 16 h 3 min
- PR mergées (30 j)
- 1
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de googleworkspace/cli
-
`gws auth login` keeps the old token cache, so API calls use a token from the previous grantOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
googleworkspace/cli#984 ·
Les mainteneurs répondent en général sous 1 jour
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
googleworkspace/cli#983 ·
Les mainteneurs répondent en général sous 1 jour
-
Replace gemini with agyOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
googleworkspace/cli#958 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
googleworkspace/cli#921 ·
Les mainteneurs répondent en général sous 1 jour
-
Add cli to awesome-ai-plugins?Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
googleworkspace/cli#920 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de googleworkspace/cli
Issues similaires
-
crate: spate-kafka priority: low tech-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: Executable check only looks at the "others" execute bit, so 0750 binaries are rejectedOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
macOS 菜单栏托盘图标保留橙色,与系统单色图标风格不一致Peut-être pris @xhugoliu l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
YizhengWw/HachimoDock#56 · 1 commentaire ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
area:ui bug effort:low P2 source:agent
Difficulté 1/5 Moins d'une heure Accessibilité débutants 86/100
Les mainteneurs répondent en général sous 1 jour