Token cache not invalidated after `gws auth login` to a different account
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #796 by @Lubrsy706 — closed without merging
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- authentication, cli
Research direction
Start in the auth login command path and trace where ~/.config/gws/credentials.enc and ~/.config/gws/token_cache.json are written or read. Reproduce by logging in as two accounts and running gws auth status plus a Gmail or Drive request; done means switching accounts no longer uses the first account's token without manually deleting the cache.
Written by the indexing model from the issue text.
Description
Bug
After running gws auth login to authenticate with a different Google account than the previously logged-in one, ~/.config/gws/credentials.enc is correctly overwritten with the new account's credentials, but ~/.config/gws/token_cache.json retains the old account's access token.
This causes all subsequent API calls to use the old account's token (until it expires ~1h later), even though gws auth status reports the new account as active.
Repro
# Account 1
gws auth login # browser → select [email protected]
gws auth status # user: [email protected] ✓
gws gmail users getProfile --params '{"userId":"me"}' # emailAddress: [email protected] ✓
# Account 2 (re-login)
gws auth login # browser → select [email protected]
gws auth status # user: [email protected] ✓ (correct)
gws gmail users getProfile --params '{"userId":"me"}' # emailAddress: [email protected] ✗ (still old account!)
gws drive files list --params '{"pageSize":3}' # owners: [email protected] ✗
# Workaround: manually clear the token cache
rm ~/.config/gws/token_cache.json
gws gmail users getProfile --params '{"userId":"me"}' # emailAddress: [email protected] ✓
Expected
gws auth login should invalidate (or remove) ~/.config/gws/token_cache.json whenever the encrypted credentials in credentials.enc change to a different account. Otherwise the cached access token from the previous account masks the new credentials until it expires.
Environment
- gws version:
0.22.5 - macOS 26.4.1 (arm64, Apple Silicon)
- Install: Homebrew (
brew install googleworkspace-cli) - Keyring backend:
keyring(default macOS Keychain)
Suggested fix
In the auth login command path, after writing credentials.enc, either:
- Remove
token_cache.jsonif it exists, OR - Compare the new account email against the cached token's identity and invalidate the cache on mismatch.
Side note (related but separate)
While we're here — multi-account workflow appears unsupported in 0.22.5:
gws auth loginhas no--accountflaggws auth listdoes not existgws --account <email>flag mentioned in some docs/runbooks isn't recognized
The current model is single-credential (one account at a time, with re-login required to switch). If multi-account is on the roadmap, this token-cache bug should be fixed regardless, since the single-credential workflow itself stumbles on it.
Contact
Filed by [email protected] — happy to provide further repro details or test patches.
- Dominant language
- Rust
- Stars
- 32.3k
- Forks
- 2k
- Avg merge
- 16h 3m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleworkspace/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
googleworkspace/cli#984 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
googleworkspace/cli#983 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
googleworkspace/cli#958 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
googleworkspace/cli#921 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
googleworkspace/cli#920 ·
Maintainers usually reply within 1 day
All issues in googleworkspace/cli
Similar issues
-
area:cli area:security bug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
status: new topic: ga4gh-sdk type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
comp-rbac
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
ClickHouse/ClickHouse#131875 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesPossibly taken @Borg93 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
lance-format/lance#11117 ·
Maintainers usually reply within 2 days