Skip to content

feat(core): port xAI SuperGrok OAuth to v2#36430

Open
watzon wants to merge 1 commit into
anomalyco:v2from
watzon:xai-oauth
Open

feat(core): port xAI SuperGrok OAuth to v2#36430
watzon wants to merge 1 commit into
anomalyco:v2from
watzon:xai-oauth

Conversation

@watzon

@watzon watzon commented Jul 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #34778

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Ports SuperGrok subscription login from V1 into the V2 XAIPlugin, so xai exposes the same OAuth methods users already know:

  1. Browser OAuthxAI Grok OAuth (SuperGrok Subscription) (PKCE + pinned 127.0.0.1:56121 callback, Grok-CLI client id, plan=generic / referrer=opencode)
  2. Device-code OAuthxAI Grok OAuth (Headless / Remote / VPS) (RFC 8628 with authorization_pending / slow_down backoff)

Token refresh is registered on both methods and runs through V2 Integration.connection.resolve (with refresh-token rotation fallback when the token endpoint omits refresh_token). Credential expiry prefers a positive expires_in, else JWT exp, else a 1h default, with a 120s skew so resolve refreshes before mid-flight expiry. The runner continues to inject credential.access as the bearer — no V1-style fetch monkey-patch.

API key / env methods still come from models-dev.

How did you verify your code works?

  • bun typecheck from packages/core
  • bun test test/plugin/provider-xai.test.ts from packages/core — 15 pass (registration, authorize URL helpers, refresh omit/rotate, JWT expires, device pending/slow_down/denied, full integration connection login against a mock server)
  • Pre-push bun turbo typecheck --concurrency=3 — all packages passed

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Register browser PKCE and headless device-code SuperGrok login methods on
the v2 XAI plugin, with refresh that falls back when refresh_token is omitted
and expires derived from expires_in or JWT exp.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant