Skip to content

Refresh TOKEN need sign in to Claude ponctually (Improve error messages) #281

Open

Description

@m21-cerutti

Description

Hello,
I got today errors like "Provider is overloaded" or "AI_APICallError: Claude token refresh is rate-limited; retry shortly." (depending GUI or Opencode Desktop).
After some investigation, seems after some time OAuth need interactive login (browser or code) and command claude -p . --model haiku fail.

Error: Failed to authenticate: OAuth session expired and could not be refreshed

Image

Would be maybe interesting to have some better messages for opencode, and maybe trying claude auth status in auth flow.

Steps to reproduce

Not sure since after login can't reproduce.
Would need delete token and handle fresh connection to Claude.

2.1.263 (Claude Code)

Operating system

Windows

Plugin version

2.1.5

OpenCode version

1.18.29

Debug logs

{"ts":"2026-09-07T10:31:50.765Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:31:50.765Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:31:50.766Z","event":"plugin_init","accountCount":1,"sources":["file"],"activeSource":"file"}
{"ts":"2026-09-07T10:31:50.766Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:31:50.766Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:31:50.766Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:31:50.767Z","event":"refresh_lock_acquired","source":"file"}
{"ts":"2026-09-07T10:31:50.767Z","event":"refresh_needed","source":"file","expiresAt":1788761576179,"expiresIn":-15534588}
{"ts":"2026-09-07T10:31:50.767Z","event":"refresh_started","source":"oauth"}
{"ts":"2026-09-07T10:31:50.987Z","event":"refresh_failed","source":"oauth","error":"HTTP 400","kind":"terminal","oauthError":"invalid_grant","oauthErrorDescription":"Refresh token expired"}
{"ts":"2026-09-07T10:31:50.987Z","event":"refresh_terminal","source":"file","status":400,"oauthError":"invalid_grant"}
{"ts":"2026-09-07T10:31:50.987Z","event":"refresh_fallback_cli","source":"file"}
{"ts":"2026-09-07T10:31:50.988Z","event":"refresh_started","source":"cli","attempt":1,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:31:51.026Z","event":"refresh_failed","source":"cli","attempt":1,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:31:51.027Z","event":"refresh_started","source":"cli","attempt":2,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:31:51.065Z","event":"refresh_failed","source":"cli","attempt":2,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:31:51.065Z","event":"refresh_cli_exhausted","source":"cli","configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:31:51.066Z","event":"refresh_exhausted","source":"file","hadCredentials":false}
{"ts":"2026-09-07T10:31:51.066Z","event":"credentials_unavailable","source":"file"}
{"ts":"2026-09-07T10:31:51.951Z","event":"auth_loader_called","authType":"oauth"}
{"ts":"2026-09-07T10:31:51.952Z","event":"auth_loader_ready","modelCount":16}
{"ts":"2026-09-07T10:31:53.312Z","event":"auth_loader_called","authType":"oauth"}
{"ts":"2026-09-07T10:31:53.312Z","event":"auth_loader_ready","modelCount":16}
{"ts":"2026-09-07T10:31:54.055Z","event":"auth_loader_called","authType":"oauth"}
{"ts":"2026-09-07T10:31:54.055Z","event":"auth_loader_ready","modelCount":16}
{"ts":"2026-09-07T10:31:57.746Z","event":"auth_loader_called","authType":"oauth"}
{"ts":"2026-09-07T10:31:57.747Z","event":"auth_loader_ready","modelCount":16}
{"ts":"2026-09-07T10:32:00.294Z","event":"auth_loader_called","authType":"oauth"}
{"ts":"2026-09-07T10:32:00.295Z","event":"auth_loader_ready","modelCount":16}
{"ts":"2026-09-07T10:32:20.807Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:32:20.808Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:32:20.808Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:20.808Z","event":"refresh_lock_acquired","source":"file"}
{"ts":"2026-09-07T10:32:20.809Z","event":"refresh_needed","source":"file","expiresAt":1788761576179,"expiresIn":-15564630}
{"ts":"2026-09-07T10:32:20.809Z","event":"refresh_started","source":"oauth"}
{"ts":"2026-09-07T10:32:20.818Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:32:20.818Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:32:20.819Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:20.819Z","event":"refresh_joined","source":"file"}
{"ts":"2026-09-07T10:32:20.997Z","event":"refresh_failed","source":"oauth","error":"HTTP 400","kind":"terminal","oauthError":"invalid_grant","oauthErrorDescription":"Refresh token expired"}
{"ts":"2026-09-07T10:32:20.998Z","event":"refresh_terminal","source":"file","status":400,"oauthError":"invalid_grant"}
{"ts":"2026-09-07T10:32:20.998Z","event":"refresh_fallback_cli","source":"file"}
{"ts":"2026-09-07T10:32:20.998Z","event":"refresh_started","source":"cli","attempt":1,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.035Z","event":"refresh_failed","source":"cli","attempt":1,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:32:21.036Z","event":"refresh_started","source":"cli","attempt":2,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.072Z","event":"refresh_failed","source":"cli","attempt":2,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:32:21.072Z","event":"refresh_cli_exhausted","source":"cli","configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.073Z","event":"refresh_exhausted","source":"file","hadCredentials":false}
{"ts":"2026-09-07T10:32:21.073Z","event":"credentials_unavailable","source":"file"}
{"ts":"2026-09-07T10:32:21.073Z","event":"credentials_unavailable","source":"file"}
{"ts":"2026-09-07T10:32:21.073Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:32:21.074Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:32:21.074Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.075Z","event":"refresh_lock_acquired","source":"file"}
{"ts":"2026-09-07T10:32:21.075Z","event":"refresh_needed","source":"file","expiresAt":1788761576179,"expiresIn":-15564896}
{"ts":"2026-09-07T10:32:21.075Z","event":"refresh_started","source":"oauth"}
{"ts":"2026-09-07T10:32:21.076Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:32:21.076Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:32:21.076Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.076Z","event":"refresh_joined","source":"file"}
{"ts":"2026-09-07T10:32:21.247Z","event":"refresh_failed","source":"oauth","error":"HTTP 400","kind":"terminal","oauthError":"invalid_grant","oauthErrorDescription":"Refresh token expired"}
{"ts":"2026-09-07T10:32:21.247Z","event":"refresh_terminal","source":"file","status":400,"oauthError":"invalid_grant"}
{"ts":"2026-09-07T10:32:21.248Z","event":"refresh_fallback_cli","source":"file"}
{"ts":"2026-09-07T10:32:21.248Z","event":"refresh_started","source":"cli","attempt":1,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.284Z","event":"refresh_failed","source":"cli","attempt":1,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:32:21.285Z","event":"refresh_started","source":"cli","attempt":2,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.320Z","event":"refresh_failed","source":"cli","attempt":2,"error":"Command failed: claude -p . --model haiku"}
{"ts":"2026-09-07T10:32:21.320Z","event":"refresh_cli_exhausted","source":"cli","configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:21.321Z","event":"refresh_exhausted","source":"file","hadCredentials":false}
{"ts":"2026-09-07T10:32:21.321Z","event":"credentials_unavailable","source":"file"}
{"ts":"2026-09-07T10:32:21.321Z","event":"credentials_unavailable","source":"file"}
{"ts":"2026-09-07T10:32:21.321Z","event":"fetch_no_credentials","modelId":"unknown"}
{"ts":"2026-09-07T10:32:21.322Z","event":"fetch_no_credentials","modelId":"unknown"}
{"ts":"2026-09-07T10:32:23.648Z","event":"cache_miss","source":"file","reason":"empty"}
{"ts":"2026-09-07T10:32:23.649Z","event":"credentials_parsed","hasAccessToken":true,"hasRefreshToken":true,"hasExpiry":true,"isMcpOnly":false}
{"ts":"2026-09-07T10:32:23.649Z","event":"credentials_file_read","success":true,"configDir":"C:\\Users\\marc2\\.claude"}
{"ts":"2026-09-07T10:32:23.649Z","event":"refresh_lock_acquired","source":"file"}
{"ts":"2026-09-07T10:32:23.649Z","event":"refresh_needed","source":"file","expiresAt":1788761576179,"expiresIn":-15567470}
{"ts":"2026-09-07T10:32:23.650Z","event":"refresh_started","source":"oauth"}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions