Skip to content

Add xAI SuperGrok/X Premium OAuth login - #677

Open
MrDllmai wants to merge 1 commit into
huggingface:mainfrom
MrDllmai:feat/xai-oauth
Open

Add xAI SuperGrok/X Premium OAuth login#677
MrDllmai wants to merge 1 commit into
huggingface:mainfrom
MrDllmai:feat/xai-oauth

Conversation

@MrDllmai

@MrDllmai MrDllmai commented Sep 4, 2026

Copy link
Copy Markdown

Motivation

xAI is already a built-in OpenAI-compatible catalog provider, but login was API-key only. SuperGrok / X Premium users can authenticate with an RFC 8628 device-code flow against auth.x.ai. This PR registers that flow in the existing tau_coding OAuth registry so /login xai works without a paid API key.

Related: #676, #370, #372.

Behavior

  • /login → Subscription lists xAI (SuperGrok / X Premium).
  • /login xai and /login xai-subscription start the device-code flow (referrer=tau).
  • /login xai-api still saves an API key.
  • Catalog auth_methods = ["api_key", "oauth"].
  • Runtime uses the access token as Bearer auth for https://api.x.ai/v1. Refresh keeps the previous refresh token if xAI omits a new one.
  • /logout xai removes the stored OAuth grant. openai-compatible OAuth logout no longer fails as a missing API key after the credential is deleted.

Tests and checks

  • uv run pytest — 1865 passed, 3 skipped
  • uv run ruff check .
  • uv run ruff format --check .
  • uv run mypy
  • hugo --minify in website/ (Hugo 0.152.2 extended)
  • Mocked HTTP covers login (referrer=tau), pending, denial, expiry, untrusted URI, malformed JSON, refresh rotation, omitted refresh token, and secret redaction
  • TUI tests cover /login xai, aliases, subscription picker, and logout messaging
  • Live device-code request with referrer=tau returned HTTP 200 (login not completed in CI)
  • Print-mode smoke: uv run tau --provider xai --model grok-4.6 -p "Reply with exactly: XAI-OAUTH-OK"

Compatibility

  • Existing XAI_API_KEY / API-key login is unchanged.
  • Device-code requests identify Tau with referrer=tau.
  • The public client ID is the one auth.x.ai already accepts for CLI device login. Replace it if xAI issues a Tau-owned client.
  • Docs: website/content/guides/providers-and-models.md, quickstart.md, slash-commands.md, dev-notes/architecture/xai-oauth.md.

Register xAI in the existing tau_coding OAuth registry so SuperGrok and
X Premium users can run /login xai without an API key. Device-code
requests identify Tau with referrer=tau. API-key login stays available
via /login xai-api.

Logout of openai-compatible OAuth providers no longer fails as a missing
API key after the stored grant is deleted.
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