Repository navigation
Description
Summary
Sign-in to the GLM Coding Plan from ZCode Desktop fails on every attempt. Browser authentication completes ("Sign-In Complete"), the zcode://oauth/callback deep link is routed correctly and the OAuth state matches, but the app's exchange request POST https://zcode.z.ai/api/v1/oauth/token receives HTTP 500 with empty body, and the UI shows "Login failed, please try again".
The endpoint appears broken server-side for all code-exchange attempts, not account-specific: a minimal curl reproduction with an obviously invalid code returns the same 500, while parameter validation still works (empty body → clean 400).
Environment
- ZCode Desktop 3.11.2, official
.deb(zcode 3.11.2-6792), single installation, Linux - Debian 13 (kernel 6.12.0-1-amd64, x64), no proxy,
zcode.z.aireachable, normal TLS - z.ai API-key mode works fine on the same machine/network — only coding-plan OAuth fails
- Account has an active paid subscription (details shared privately via [email protected])
Reproduction A — in-app
- Settings → connect GLM Coding Plan (z.ai global) → Login
- Complete browser sign-in ("Sign-In Complete")
- Redirect to
zcode://oauth/callbackarrives, state matches (app log:OAuth 回调路由成功 ... completed: true) - App sends
POST https://zcode.z.ai/api/v1/oauth/token→ HTTP 500 → "Login failed, please try again"
Happens on 100% of attempts today (2026-09-08, ~15+ attempts between 13:27 and 14:45 UTC+3).
Reproduction B — minimal curl, no account, no client
curl -sS -X POST -H "Content-Type: application/json" \
-d '{"provider":"zai","code":"AAAAAAAAAAAAAAAAA","codeLength":17,"redirect_uri":"https://zcode.z.ai/app/oauth/login?redirect=zcode%3A%2F%2Foauth%2Fcallback&app_version=3.11.2","state":"00000000000000000000000000000000"}' \
https://zcode.z.ai/api/v1/oauth/tokenActual result:
HTTP 500
{"code":2007,"msg":"http error"}
Expected: a clean 4xx (e.g. invalid_code / invalid_grant) for a garbage code.
Control case showing the endpoint itself is alive and validates parameters:
curl -sS -X POST -H "Content-Type: application/json" -d '{}' https://zcode.z.ai/api/v1/oauth/token
# HTTP 400 {"code":3001,"msg":"parameter error"}So the failure (error code 2007, "http error") sits in the exchange handling — likely an upstream call from the API failing — before any account or code validation.
Server request IDs from real login attempts
2026090811450158b0f7ab82adc6c4d9ba— 2026-09-08 11:45:02 UTC20260908113701813e652be62b2ecacc9d— 2026-09-08 11:37:01 UTC
Client log evidence (2026-09-08 14:45 UTC+3)
[oauthService][trace:OAuth polling flow started] {"expiresInMs":299516,"pollIntervalMs":2000,"provider":"zai"}
[deep-link] OAuth 回调路由成功 { state: '5aa97af1…', windowId: 1, provider: 'zai', completed: true }
[zaiOAuth] token request {"method":"POST","url":"https://zcode.z.ai/api/v1/oauth/token","headers":{"Content-Type":"application/json"},"body":{"provider":"zai","code":"code…2ebd","codeLength":17,"redirect_uri":"https://zcode.z.ai/app/oauth/login?redirect=zcode%3A%2F%2Foauth%2Fcallback&app_version":"3.11.2","state":"5aa97af1…"}}
[zaiOAuth] token response error {"method":"POST","url":"https://zcode.z.ai/api/v1/oauth/token","status":500,"responseHeaders":{"x-request-id":"2026090811450158b0f7ab82adc6c4d9ba"}}
[rpc:call] oauth.handleCallback FAIL (667.4ms) {"name":"ApiError","message":"http error", …}
Notes
- Possibly related: [Bug] Z.ai OAuth succeeds but ZCode fails with zai_oauth_required on Ubuntu #116 — but that report's token response succeeded (code 0) and the failure was in
ZaiBusinessTokenResolver.exchangeBusinessToken; here the token endpoint itself 500s for everyone, which may be the upstream cause of that symptom. - Earlier "OAuth state mismatch" failures were caused by a coexisting AppImage +
.debfighting over thezcode://handler; resolved by removing the AppImage. The HTTP 500 is independent of that and remains.
Happily provide full logs or run any server-side-adjacent diagnostics you need.
Activity
github-actions commentedon Sep 8, 2026
👋 感谢你的反馈,我们已经收到。
status: 待评估,你可以随时补充信息。needs: 更多信息标签并 @ 你。👋 Thanks — we've received your issue.
status: 待评估(Triage); feel free to add context.needs: 更多信息and ping you.AI-Chef commentedon Sep 9, 2026
me too
jadmadi commentedon Sep 16, 2026
Currently I'm using the API and losing access to this generous offer.
I'm trying to document the case and share what is happening. I signed up for an annual subscription because it was appealing, but due to issue #575, I lost the leverage I should be enjoying.
Taking into consideration that the root cause of #575 is not my machine, network, or personal setup, and is not something I have the leverage to fix, else I would.
matiasgel commentedon Sep 21, 2026
ZCode 3.14.1 on Ubuntu/Linux.
Browser OAuth authentication succeeds and the zcode:// callback
is routed correctly:
OAuth 回调路由成功
completed: true
ZCode then requests:
POST https://zcode.z.ai/api/v1/oauth/token
and receives:
HTTP 500
x-request-id: 20260921231516fc9596714a422a354e5f
The client subsequently reports:
zai_oauth_required
oauth.handleCallback FAIL
ApiError: http error
This appears to be the same server-side issue reported in #575,
but it is still reproducible on ZCode 3.14.1.
jadmadi commentedon Sep 22, 2026
Update: Still failing on ZCode 3.14.3 (2026-09-22)
The bug is not fixed in the latest release. Same exact failure, same endpoint, same 500.
Environment: ZCode 3.14.3 (deb, Linux x64, Ubuntu/Debian),
provider: zai, coding-plan connection.Client-side evidence (today's attempts)
Second attempt the same minute →
x-request-id: 20260922103746af3ef5380e10fb8c05, also 500.The deep-link callback routing, state validation, and browser handshake all succeed. The only failing step is the token exchange on your side.
Root cause isolated — minimal server-side reproduction
I probed
POST https://zcode.z.ai/api/v1/oauth/tokendirectly with synthetic data (no account involved). The endpoint returns a clean 400{"code":3001,"msg":"parameter error"}for most payloads, but reliably returns 500{"code":2007,"msg":"http error"}whenever the request body contains both astatefield and aredirect_urifield.provider+codeprovider+code+codeLengthprovider+code+stateprovider+code+redirect_uriprovider+code+codeLength+stateprovider+code+codeLength+redirect_uriprovider+code+state+redirect_uriThe 500 is value-independent — it triggers with a dummy hex state and
redirect_uri: "https://example.com/cb", and reproduces consistently on repeat. The crash is caused by the presence of both fields, not their contents.This matters because the ZCode desktop client always sends both
stateandredirect_uri(see the logged request body above). So the official OAuth flow can never complete — the client is sending a perfectly valid request that your token endpoint crashes on.Conclusion
This is a server-side bug in
POST /api/v1/oauth/token, triggered by the combination ofstate+redirect_uriin the request body. It is not account-specific, not client-version-specific (fails identically on 3.11.2, 3.14.1 per @matiasgel, and 3.14.3), and not Linux-specific.Suggested server-side fix: the handler for
state+redirect_urithrows or errors out before returning a response. Likely an unhandled null/exception in the branch that consumes those two fields together.I have a paid Coding Plan I cannot activate. Any status update or ETA would be greatly appreciated — happy to test a fix as soon as one is available.
wesleymatosdev commentedon Sep 24, 2026
Adding data from macOS — I hit the identical failure on Sep 4–5, i.e. before this issue was filed, which pushes the server-side window back and adds a cross-platform data point (all other reports so far are Linux/.deb).
Environment
zcode://oauth/callbackroutes correctly with matching state, thenPOST https://zcode.z.ai/api/v1/oauth/token→ HTTP 500 → "Login failed, please try again"Client log evidence
Sep 4, 01:31 UTC-3 (v3.10.2):
Sep 5, 15:40 and 15:42 UTC-3 (v3.11.2) — two more attempts, same 500:
Three observations that may help triage
[oauthService][trace:OAuth polling flow completed]is misleading. At 15:40:07 on Sep 5 this "completed" trace was logged ~2.5s after the 500 andoauth.handleCallback FAIL. Anyone grepping logs for "completed" will misread a failed flow as success (I did, initially). Suggest renaming it to something likepolling flow endedor including the outcome.restoreCachedSession restored: zai) and OAuth coding-plan mode has worked since (~Sep 8 onward). I never determined whether the server was fixed or a retry finally landed — but it suggests the breakage is intermittent/partial rather than a hard outage, and bounds the bad window to roughly Sep 4 – early Sep 8 for at least one account. The reports here of it still failing on 3.14.3 (Sep 21–22) suggest it regressed or is flapping since.Happy to pull the full log lines or request IDs if useful.
romangalaxys10-spec commentedon Sep 25, 2026
Additional Field Telemetry: Windows 11 Reproduction & Cross-Platform Confirmation
Discord Incident Reference:
#report-a-bugThread 1545496971845050438Dmiiitiwin 11 pro), ZCode Desktop"Login failed, please try again"(options:Retry login/Cancel)Reproduction Characteristics:
POST /api/v1/oauth/tokenreturningHTTP 500 {"code":2007,"msg":"http error"}regardless of OS host platform.Cross-linking to correlate with #523 and consolidate triage for engineering teams.
AUTENTK-EU commentedon Oct 23, 2026
Related case here (different endpoint, same signature):
POST https://api.z.ai/api/auth/z/loginwith the accessToken saved by a successfulzcode login zaireturns200 {"code":500,"msg":"Z.ai user information is invalid"}— same result with the zcode JWT and with every API key of the account. Consequence: promo plan «ZCode 1024 Dev Day» active at billing but 0 model requests served (Desktop + CLI 0.16.9, macOS arm64, Oct 23). Full details: #1180hamidi2 commentedon Oct 25, 2026
Still reproducing on 2026-10-25, ZCode Desktop 3.16.3 (Linux x86_64).
Symptoms are identical: browser sign-in completes, the zcode:// callback
routes successfully, then POST https://zcode.z.ai/api/v1/oauth/token
returns HTTP 500 {"code":2007,"msg":"http error"} on every attempt.
Ruled out on my side:
Server request IDs from my failed exchanges (today):
I also can't access my 5-hour/weekly reset quotas or the 500M promo
tokens because they're tied to the logged-in session, so this bug is
effectively blocking part of a paid plan. Almost 2 months open with P2
label and no fix — could this please get some attention?
balupton commentedon Oct 25, 2026
This also prevented my partner and I from accessing our plans on all our work machines and the promos, we've let the plans expire. Didn't get a refund either.
Black-Japan-Tea commentedon Nov 4, 2026
+1 — fresh confirmation, and still broken after updating to 3.17.2 (latest).
Environment: Windows 10 x64 (10.0.19045), ZCode Desktop 3.16.2 → updated to 3.17.2 on 2026-11-04 (auto-updater confirms the app is now on 3.17.2,
latest version: 3.17.2), re-attempted sign-in after the update — the flow fails identically.Local causes ruled out (evidence from desktop logs, 3.16.2, 2026-11-04):
zcode://protocol handler is registered correctly (HKCU\Software\Classes\zcode+HKCR\zcode) — thezcode://oauth/callbackdeep link does fire;[oauthService] restoreCachedSession skipped: no active provider;"availability":"unavailable","entitled":false,"unavailableReason":"not-connected"— the desktop app never receives the exchanged token, while the browser session is fully logged in (chats visible).Fresh anonymous probing of
POST https://zcode.z.ai/api/v1/oauth/token(2026-11-05,application/json, no account involved, three requests from the same IP seconds apart):{}HTTP 400—{"code":3001,"msg":"parameter error"}{"state":"probe"}HTTP 400—{"code":3001,"msg":"parameter error"}{"state":"probe","redirect_uri":"zcode://oauth/callback"}← the combination the client always sendsHTTP 429— empty bodyThe
500 {"code":2007,"msg":"http error"}signature reported earlier has apparently changed to a bareHTTP 429with no JSON body. The empty body (nocode/msg) suggests an edge/WAF or rate-limiter rule intercepting thestate+redirect_uricombination rather than the API handler itself — but the effect is unchanged: control payloads pass while the exact payload the client must send is still rejected, so the official OAuth flow still cannot complete server-side.Additional impact: this blocks more than Coding Plan login. With no OAuth session the app never issues remote-control credentials (
web-remote-control:external-relaystays empty), so account-gated features like connecting a phone / remote control are locked as well.— @Black-Japan-Tea, 2026-11-05
ctangarife commentedon Nov 22, 2026
Fresh reproduction on 2026-11-22, ZCode Desktop 3.19.1, Linux x64 (Bazzite / Fedora 45) — same endpoint, slightly different server response than the HTTP 500/{"code":2007} above: HTTP 400 with
oauth authorization code is invalid or expired, returned for every attempt with fresh, immediately-exchanged codes.Local chain fully verified working, so this is not client-side:
zcode://oauth/callbackdeep link routes correctly — desktop log showsOAuth 回调路由成功 {completed:true}with the matchingstate.POST https://zcode.z.ai/api/v1/oauth/token→ rejected400.stopped reason=auth-requiredafter the previous session's tokens expired).Request IDs from today's failed exchanges (2026-11-22 ~18:06–18:16 UTC):
20261122180644958655a65bfd3e59bc99202611221807095c1063895f2a2de7cf30202611221807429c8e800023c73a91fd7b2026112218092935f3ef6062f19441791120261122181639b079534c1891b51a5fabHappy to provide full desktop logs for any of these request IDs. Related client-side analysis in #1545 (different root cause — local Secret Service — but same "login cannot complete" impact).
ctangarife commentedon Nov 22, 2026
Definitive proof this is server-side, captured just now (2026-11-22 18:25:49 UTC):
A raw
curlraced the desktop app and was first to exchange a brand-new authorization code — captured from the process arguments <1 second after the browser issued the redirect, so expiry is physically impossible:ctangarife commentedon Nov 22, 2026
Definitive proof this is server-side, captured just now (2026-11-22 18:25:49 UTC):
A raw
curlraced the desktop app and was first to exchange a brand-new authorization code — captured from the process arguments <1 second after the browser issued the redirect, so expiry is physically impossible:The desktop app's own exchange 1s later got the same 400 (x-request-id
202611221825500426289f1...). This eliminates every client-side factor: no app, no browser, no deep link, no timing, no TLS/proxy. The authorization service is issuing codes it cannot validate at exchange time — consistent with the 500/2007 reports above (the token service appears unable to reach its backing store).This is now blocking: account login (UI stuck at "Connect"), and consequently the mobile / web-remote-control feature, for paying Coding Plan users. Two months at P2 with multi-platform confirmations — please escalate. Full logs available on request.