fix: keep web-to-build SSO device flow off Cloudflare-strict accounts.x.ai - #929
Merged
Merged
Conversation
….x.ai accounts.x.ai rejects non-browser clients (including the managed tls-client) with HTTP 403 even when a valid cf_clearance is presented, while auth.x.ai accepts them. Move the device flow onto auth.x.ai: - Solve an ad-hoc clearance for accounts.x.ai through the same egress exit (new Manager.SolveClearance, never persisted into the node cache) and attach it to the flow, falling back gracefully when solving fails. - Degrade the SSO precheck and the verification-page warmup to warnings when Cloudflare blocks them; credential validity is now judged by the verify step, which still maps dead SSO cookies to ErrUnauthorized (preserving the credential-rejected marker) via the sign-in redirect. - Stop following redirects on verify/approve POSTs and read the 302 Location directly for the consent/done markers, so the flow never visits accounts.x.ai. Verified with go test ./... and a live conversion (created 1, failed 0). Co-Authored-By: Claude <noreply@anthropic.com>
heshangcode
force-pushed
the
fix/web-sso-build-conversion
branch
from
August 14, 2026 08:31
8651b6b to
ecf070b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Converting a Grok Web (SSO) account to a Build account fails with
校验 Grok Web SSO 失败: xAI OAuth HTTP 403on the first request toaccounts.x.ai, regardless of proxy/egress quality.Root cause
accounts.x.airuns strict Cloudflare bot management that rejects non-browser clients — including the managedtls-client— with HTTP 403 even when a validcf_clearanceis presented (verified empirically: same exit IP + same clearance → curl_cffi Chrome fingerprint passes, tls-client gets 403). Meanwhileauth.x.aiaccepts plain clients without any clearance.The old flow required three
accounts.x.airound-trips:GET accounts.x.ai— non-essential, only early-detects dead SSO cookiesGET verification_uri_complete(accounts.x.ai) — page warm-up only, not required by xAIaccounts.x.aiconsent/done pagesFix
Move the entire device flow onto
auth.x.ai:accounts.x.aivia newManager.SolveClearance(never persisted, so the node's grok.com clearance is untouched); attached to the flow when solving succeeds, graceful fallback otherwise.Locationdirectly for theconsent/donemarkers, soaccounts.x.aiis never visited.ErrUnauthorized(preserving themarkSSOCredentialRejectedbehavior) via the sign-in redirect on the verify step.Verification
go test ./...green; 5 new tests cover clearance attach/fallback, cookie-header sanitization, blocked-precheck degradation, dead-SSO →ErrUnauthorizedmapping, and no-redirect-follow behavior.created: 1, linked: 0, skipped: 0, failed: 0, synced: 1.Known limitation
If xAI moves the consent/done markers from the first 302
Locationto a later hop or JS-rendered page, conversion will fail with a readableSSO 自动验证 Device Flow 失败error instead of silently misbehaving.🤖 Generated with Claude Code