[GH-ISSUE #49] 没有自动刷新 token #42

Closed
opened 2026-02-27 15:38:06 +03:00 by kerem · 3 comments
Owner

Originally created by @benny-eu on GitHub (Feb 21, 2026).
Original GitHub issue: https://github.com/NikkeTryHard/zerogravity/issues/49

What happened?

token一小时后没有自动刷新,导致请求错误

How to reproduce

No response

Diagnostic Report

generated_at: 2026-02-21T17:54:19Z
format: TOON/1.0
system:
  os: Linux
  kernel: 6.12.68-linuxkit
  arch: aarch64
  distro: Debian GNU/Linux 13 (trixie)
  glibc: ldd (Debian GLIBC 2.41-12+deb13u1) 2.41
  memory_total: 7.7Gi
  memory_available: 6.9Gi
  in_docker: true
zerogravity:
  version: 1.3.0
  dev_build: false
  zg_binary: <install_dir>/bin/zg
  main_binary: <install_dir>/bin/zerogravity
  main_binary_size: 8500688
  main_binary_max_glibc: GLIBC_2.17
service:
  running: true
  proxy_port: 8741
  mitm_port: 8742
config:
  config_dir: ~/.config/zerogravity
  token_file_exists: true
  token_file_length: 260
  token_age: 0h1m
  token_env_set: true
  api_key_set: true
  env:
    rust_log: info
    zerogravity_ls_path: /usr/local/bin/language_server_linux_x64
ls_binary:
  path: /usr/local/bin/language_server_linux_x64
  size_bytes: 171132280
  executable: true
api:
  health: "{\"status\":\"ok\"}"
  models: "{\"data\":[{\"created\":1700000000,\"id\":\"opus-4.6\",\"meta\":{\"enum_value\":1026,\"label\":\"Claude Opus 4.6 (Thinking)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"opus-4.6\"},{\"created\":1700000000,\"id\":\"sonnet-4.6\",\"meta\":{\"enum_value\":1035,\"label\":\"Claude Sonnet 4.6 (Thinking)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"sonnet-4.6\"},{\"created\":1700000000,\"id\":\"gemini-3-flash\",\"meta\":{\"enum_value\":1018,\"label\":\"Gemini 3 Flash\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3-flash\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro\",\"meta\":{\"enum_value\":1037,\"label\":\"Gemini 3.1 Pro (High)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro-high\",\"meta\":{\"enum_value\":1037,\"label\":\"Gemini 3.1 Pro (High)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro-high\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro-low\",\"meta\":{\"enum_value\":1036,\"label\":\"Gemini 3.1 Pro (Low)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro-low\"}],\"object\":\"list\"}"
  quota: "{\"account_banned\":false,\"account_restricted\":false,\"last_updated\":\"2026-02-21T17:53:59.582078007+00:00\",\"models\":[{\"label\":\"Gemini 3.1 Pro (High)\",\"model_id\":\"MODEL_PLACEHOLDER_M37\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"4h 58m\",\"reset_in_secs\":17937,\"reset_time\":\"2026-02-21T22:52:57Z\"},{\"label\":\"Gemini 3.1 Pro (Low)\",\"model_id\":\"MODEL_PLACEHOLDER_M36\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"4h 58m\",\"reset_in_secs\":17937,\"reset_time\":\"2026-02-21T22:52:57Z\"},{\"label\":\"Gemini 3 Flash\",\"model_id\":\"MODEL_PLACEHOLDER_M18\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 43m\",\"reset_in_secs\":2620,\"reset_time\":\"2026-02-21T18:37:40Z\"},{\"label\":\"Claude Sonnet 4.6 (Thinking)\",\"model_id\":\"MODEL_PLACEHOLDER_M35\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"},{\"label\":\"Claude Opus 4.6 (Thinking)\",\"model_id\":\"MODEL_PLACEHOLDER_M26\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"},{\"label\":\"GPT-OSS 120B (Medium)\",\"model_id\":\"MODEL_OPENAI_GPT_OSS_120B_MEDIUM\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"}],\"plan\":{\"plan_name\":\"Pro\",\"tier_id\":\"g1-ultra-tier\",\"tier_name\":\"Google AI Ultra\"}}"
  usage: "{\"mitm\":{\"per_model\":{\"claude-opus-4-6-thinking\":{\"cache_creation_tokens\":0,\"cache_read_tokens\":0,\"input_tokens\":98700,\"output_tokens\":620,\"requests\":1},\"gemini-3-flash\":{\"cache_creation_tokens\":0,\"cache_read_tokens\":0,\"input_tokens\":10332,\"output_tokens\":76,\"requests\":2}},\"total_cache_creation_tokens\":0,\"total_cache_read_tokens\":0,\"total_input_tokens\":109032,\"total_output_tokens\":696,\"total_requests\":3,\"total_response_output_tokens\":0,\"total_thinking_output_tokens\":249,\"total_tokens\":109728}}"

Additional Context

diagnostic.toon.zip

Originally created by @benny-eu on GitHub (Feb 21, 2026). Original GitHub issue: https://github.com/NikkeTryHard/zerogravity/issues/49 ### What happened? token一小时后没有自动刷新,导致请求错误 ### How to reproduce _No response_ ### Diagnostic Report ```text generated_at: 2026-02-21T17:54:19Z format: TOON/1.0 system: os: Linux kernel: 6.12.68-linuxkit arch: aarch64 distro: Debian GNU/Linux 13 (trixie) glibc: ldd (Debian GLIBC 2.41-12+deb13u1) 2.41 memory_total: 7.7Gi memory_available: 6.9Gi in_docker: true zerogravity: version: 1.3.0 dev_build: false zg_binary: <install_dir>/bin/zg main_binary: <install_dir>/bin/zerogravity main_binary_size: 8500688 main_binary_max_glibc: GLIBC_2.17 service: running: true proxy_port: 8741 mitm_port: 8742 config: config_dir: ~/.config/zerogravity token_file_exists: true token_file_length: 260 token_age: 0h1m token_env_set: true api_key_set: true env: rust_log: info zerogravity_ls_path: /usr/local/bin/language_server_linux_x64 ls_binary: path: /usr/local/bin/language_server_linux_x64 size_bytes: 171132280 executable: true api: health: "{\"status\":\"ok\"}" models: "{\"data\":[{\"created\":1700000000,\"id\":\"opus-4.6\",\"meta\":{\"enum_value\":1026,\"label\":\"Claude Opus 4.6 (Thinking)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"opus-4.6\"},{\"created\":1700000000,\"id\":\"sonnet-4.6\",\"meta\":{\"enum_value\":1035,\"label\":\"Claude Sonnet 4.6 (Thinking)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"sonnet-4.6\"},{\"created\":1700000000,\"id\":\"gemini-3-flash\",\"meta\":{\"enum_value\":1018,\"label\":\"Gemini 3 Flash\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3-flash\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro\",\"meta\":{\"enum_value\":1037,\"label\":\"Gemini 3.1 Pro (High)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro-high\",\"meta\":{\"enum_value\":1037,\"label\":\"Gemini 3.1 Pro (High)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro-high\"},{\"created\":1700000000,\"id\":\"gemini-3.1-pro-low\",\"meta\":{\"enum_value\":1036,\"label\":\"Gemini 3.1 Pro (Low)\"},\"object\":\"model\",\"owned_by\":\"antigravity\",\"parent\":null,\"permission\":[],\"root\":\"gemini-3.1-pro-low\"}],\"object\":\"list\"}" quota: "{\"account_banned\":false,\"account_restricted\":false,\"last_updated\":\"2026-02-21T17:53:59.582078007+00:00\",\"models\":[{\"label\":\"Gemini 3.1 Pro (High)\",\"model_id\":\"MODEL_PLACEHOLDER_M37\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"4h 58m\",\"reset_in_secs\":17937,\"reset_time\":\"2026-02-21T22:52:57Z\"},{\"label\":\"Gemini 3.1 Pro (Low)\",\"model_id\":\"MODEL_PLACEHOLDER_M36\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"4h 58m\",\"reset_in_secs\":17937,\"reset_time\":\"2026-02-21T22:52:57Z\"},{\"label\":\"Gemini 3 Flash\",\"model_id\":\"MODEL_PLACEHOLDER_M18\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 43m\",\"reset_in_secs\":2620,\"reset_time\":\"2026-02-21T18:37:40Z\"},{\"label\":\"Claude Sonnet 4.6 (Thinking)\",\"model_id\":\"MODEL_PLACEHOLDER_M35\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"},{\"label\":\"Claude Opus 4.6 (Thinking)\",\"model_id\":\"MODEL_PLACEHOLDER_M26\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"},{\"label\":\"GPT-OSS 120B (Medium)\",\"model_id\":\"MODEL_OPENAI_GPT_OSS_120B_MEDIUM\",\"remaining_fraction\":1.0,\"remaining_pct\":100.0,\"reset_in_human\":\"0h 22m\",\"reset_in_secs\":1358,\"reset_time\":\"2026-02-21T18:16:38Z\"}],\"plan\":{\"plan_name\":\"Pro\",\"tier_id\":\"g1-ultra-tier\",\"tier_name\":\"Google AI Ultra\"}}" usage: "{\"mitm\":{\"per_model\":{\"claude-opus-4-6-thinking\":{\"cache_creation_tokens\":0,\"cache_read_tokens\":0,\"input_tokens\":98700,\"output_tokens\":620,\"requests\":1},\"gemini-3-flash\":{\"cache_creation_tokens\":0,\"cache_read_tokens\":0,\"input_tokens\":10332,\"output_tokens\":76,\"requests\":2}},\"total_cache_creation_tokens\":0,\"total_cache_read_tokens\":0,\"total_input_tokens\":109032,\"total_output_tokens\":696,\"total_requests\":3,\"total_response_output_tokens\":0,\"total_thinking_output_tokens\":249,\"total_tokens\":109728}}" ``` ### Additional Context [diagnostic.toon.zip](https://github.com/user-attachments/files/25460072/diagnostic.toon.zip)
kerem 2026-02-27 15:38:06 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@NikkeTryHard commented on GitHub (Feb 22, 2026):

Fixed in v1.3.0 (commit 33a961c) — the proxy now periodically refreshes OAuth tokens and the MITM layer swaps the auth header on outgoing requests automatically.

If you update to the latest version this should be resolved. Thanks for the detailed logs — they helped confirm the fix was targeting the right issue. 🙏

<!-- gh-comment-id:3940078892 --> @NikkeTryHard commented on GitHub (Feb 22, 2026): Fixed in v1.3.0 (commit 33a961c) — the proxy now periodically refreshes OAuth tokens and the MITM layer swaps the auth header on outgoing requests automatically. If you update to the latest version this should be resolved. Thanks for the detailed logs — they helped confirm the fix was targeting the right issue. 🙏
Author
Owner

@NikkeTryHard commented on GitHub (Feb 22, 2026):

Looking at your diagnostic report more carefully — I see token_env_set: true which means you're using ZEROGRAVITY_TOKEN (a raw access token). Raw access tokens expire after ~1 hour and cannot be refreshed — there's no refresh token to renew them with.

The auto-refresh fix only works with account-based auth (refresh tokens). To switch:

# Extract a refresh token from your Antigravity installation
zg extract

# Or add an account manually inside the container
curl -X POST http://localhost:8741/v1/accounts \
  -H "Content-Type: application/json" \
  -d '{"email":"your@email.com","refresh_token":"1//your-refresh-token"}'

With accounts.json, the proxy will automatically refresh tokens before they expire. No more 401s after 1 hour. 👍

<!-- gh-comment-id:3940083500 --> @NikkeTryHard commented on GitHub (Feb 22, 2026): Looking at your diagnostic report more carefully — I see `token_env_set: true` which means you're using `ZEROGRAVITY_TOKEN` (a raw access token). **Raw access tokens expire after ~1 hour and cannot be refreshed** — there's no refresh token to renew them with. The auto-refresh fix only works with **account-based auth** (refresh tokens). To switch: ```bash # Extract a refresh token from your Antigravity installation zg extract # Or add an account manually inside the container curl -X POST http://localhost:8741/v1/accounts \ -H "Content-Type: application/json" \ -d '{"email":"your@email.com","refresh_token":"1//your-refresh-token"}' ``` With accounts.json, the proxy will automatically refresh tokens before they expire. No more 401s after 1 hour. 👍
Author
Owner

@benny-eu commented on GitHub (Feb 22, 2026):

我检查了 docker compose,并没有注入ZEROGRAVITY_TOKEN,为什么token_env_set 会是 true 呢?

<!-- gh-comment-id:3940528202 --> @benny-eu commented on GitHub (Feb 22, 2026): 我检查了 docker compose,并没有注入ZEROGRAVITY_TOKEN,为什么token_env_set 会是 true 呢?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/zerogravity#42
No description provided.