gws auth login can silently leave a stale/split token cache, causing 403 insufficient authentication scopes after re-auth
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
- #959 de @phatmandrake — fechado sem integrar
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 48/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- rust
- Domínio
- authentication, cli
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Rust
- Estrelas
- 32.3k
- Forks
- 2k
- Merge médio
- 16h 3min
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleworkspace/cli
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
googleworkspace/cli#984 ·
Mantenedores costumam responder em até 1 dia
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
googleworkspace/cli#983 ·
Mantenedores costumam responder em até 1 dia
-
Replace gemini with agyAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 82/100
googleworkspace/cli#958 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
googleworkspace/cli#921 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
googleworkspace/cli#920 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleworkspace/cli
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
matrix-org/matrix-rust-sdk#7495 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
yantrikos/yantrik-os#1272 ·
Mantenedores costumam responder em até 1 dia
-
crate: spate-kafka priority: low tech-debt
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: Executable check only looks at the "others" execute bit, so 0750 binaries are rejectedAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
macOS 菜单栏托盘图标保留橙色,与系统单色图标风格不一致Talvez já em andamento @xhugoliu assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
YizhengWw/HachimoDock#56 · 1 comentário ·