`gws auth login` keeps the old token cache, so API calls use a token from the previous grant
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 80/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- rust
- Bereich
- authentication, cli
Rechercherichtung
Beginne in crates/google-workspace-cli/src/auth_commands.rs bei handle_login_inner, wo die neuen Anmeldedaten gespeichert werden, und vergleiche es mit handle_logout, das den Cache bereits löscht. Füge nach dem Speichern das Entfernen von token_cache.json und sa_token_cache.json hinzu und prüfe dann select_scope in main.rs, um zu bestätigen, wie gecachte Tokens nach Scope-Set verschlüsselt werden. Fertig, wenn eine erneute Anmeldung mit einem breiteren Scope und der Aufruf einer Gmail-Methode keinen 403 mehr zurückgibt und die Auth-Tests bestehen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
This report was written by an AI coding agent (Claude Code) that diagnosed the fault on its user's machine. "The agent" below is that agent.
Observed
On the user's machine, after gws auth login, API calls kept failing with 403 errors although gws auth status reported the correct scopes and "token_valid": true.
$ gws gmail users drafts create --params '{"userId":"me"}' --json '{"message":{"raw":"..."}}'
{
"error": {
"code": 403,
"message": "Missing access token for authorization. Request: MailboxService.CreateDraft",
"reason": "forbidden"
}
}
$ gws gmail users messages modify --params '{"userId":"me","id":"..."}' --json '{"addLabelIds":["STARRED"]}'
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes."
}
}
In the same state, gmail users messages list, gmail users labels create and gmail users messages insert succeeded, and gws auth status listed https://www.googleapis.com/auth/gmail.modify.
The files in the config directory showed that the login had written new credentials and left the cache:
credentials.enc 10:47
token_cache.json 10:45
The agent moved token_cache.json aside, and every call then succeeded.
Expected
gws auth login replaces the credentials, so the next API call uses a token from the new grant.
Cause
handle_login_innerincrates/google-workspace-cli/src/auth_commands.rssaves the new credentials and does not touchtoken_cache.json. Onlyhandle_logoutdeletes it.select_scopeinmain.rsasks for the first scope of each method, and the cache stores one token for each scope set. Every Gmail method listshttps://mail.google.com/first, so all Gmail calls share one cached entry.gws auth statusgets a new token for itstokeninfocheck, so it reports the new grant while API calls still use the cached token.
Steps to reproduce
The agent observed the end state above and did not run this exact sequence:
gws auth loginwith a narrow scope set, then call a Gmail method so a token is cached.gws auth loginagain with a wider scope set.- Call a method that needs the new scope. It fails with a 403 until the cached token is replaced.
Proposed fix
Delete token_cache.json and sa_token_cache.json in the login path, after the new credentials are saved.
Related
#188 reported the same symptom and was closed with a manual workaround (delete the stale cache).
Environment
- gws 0.22.5, built from source
- macOS, keyring backend
the scratch file is removed; the text on stdout is the only copy
- Vorherrschende Sprache
- Rust
- Sterne
- 32.3k
- Forks
- 2k
- Ø Merge
- 16 Std. 3 Min.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus googleworkspace/cli
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
googleworkspace/cli#983 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Replace gemini with agyOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
googleworkspace/cli#958 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
googleworkspace/cli#921 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
googleworkspace/cli#920 ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs(gmail): the --draft tip prints a send command that fails (users.drafts.send --body)Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
googleworkspace/cli#914 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in googleworkspace/cli
Ähnliche Issues
-
area:cli area:security bug priority:medium
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
rtk-ai/rtk#5127 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
status: new topic: ga4gh-sdk type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Maintainer antworten meist innerhalb von 1 Tag
-
comp-rbac
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
ClickHouse/ClickHouse#131875 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesEvtl. vergeben @Borg93 hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
lance-format/lance#11117 ·
Maintainer antworten meist innerhalb von 2 Tagen