`gws auth login` keeps the old token cache, so API calls use a token from the previous grant
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 80/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- rust
- Domínio
- authentication, cli
Direção de pesquisa
Comece em crates/google-workspace-cli/src/auth_commands.rs em handle_login_inner, onde as novas credenciais são salvas, e compare com handle_logout, que já exclui o cache. Adicione a remoção de token_cache.json e sa_token_cache.json após o salvamento, depois verifique select_scope em main.rs para confirmar como os tokens em cache são indexados por conjunto de escopos. Concluído quando fazer login novamente com um escopo mais amplo e chamar um método do Gmail não retornar mais 403, com os testes de autenticação passando.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- 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
-
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
-
docs(gmail): the --draft tip prints a send command that fails (users.drafts.send --body)Talvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
googleworkspace/cli#914 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de googleworkspace/cli
Issues semelhantes
-
area:cli area:security bug priority:medium
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
rtk-ai/rtk#5127 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
status: new topic: ga4gh-sdk type: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia
-
comp-rbac
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
ClickHouse/ClickHouse#131875 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesTalvez já em andamento @Borg93 assumiu hoje. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
lance-format/lance#11117 ·
Mantenedores costumam responder em até 2 dias