`gws auth login` keeps the old token cache, so API calls use a token from the previous grant
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 80/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- authentication, cli
Hướng nghiên cứu
Bắt đầu trong crates/google-workspace-cli/src/auth_commands.rs tại handle_login_inner, nơi thông tin xác thực mới được lưu, và so sánh với handle_logout, nơi đã xóa bộ nhớ đệm. Thêm việc xóa token_cache.json và sa_token_cache.json sau khi lưu, sau đó kiểm tra select_scope trong main.rs để xác nhận cách các token được lưu trong bộ nhớ đệm được khóa theo tập hợp scope. Hoàn thành khi đăng nhập lại với scope rộng hơn và gọi một phương thức Gmail không còn trả về 403, với các bài kiểm thử xác thực đều vượt qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Rust
- Star
- 32.3k
- Fork
- 2k
- Merge trung bình
- 16 giờ 3 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleworkspace/cli
-
auth export masks secrets by default with no warning; consumers fail later with invalid_clientĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
googleworkspace/cli#983 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Replace gemini with agyĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
googleworkspace/cli#958 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleworkspace/cli#921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add cli to awesome-ai-plugins?Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
googleworkspace/cli#920 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(gmail): the --draft tip prints a send command that fails (users.drafts.send --body)Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleworkspace/cli#914 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleworkspace/cli
Issue tương tự
-
area:cli area:security bug priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
rtk-ai/rtk#5127 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: new topic: ga4gh-sdk type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
comp-rbac
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ClickHouse/ClickHouse#131875 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug(python): read_transaction raises TypeError on a Rewrite with rewritten indicesCó thể đã có người làm @Borg93 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
lance-format/lance#11117 ·
Maintainer thường phản hồi trong vòng 2 ngày