tweak(opencode): make xAI OAuth device-only to reduce confusion w/ headless environments (#40537)
This commit is contained in:
@@ -2308,9 +2308,9 @@ Some useful routing options:
|
||||
|
||||
### xAI
|
||||
|
||||
Three ways to authenticate: a SuperGrok subscription via browser OAuth, the same SuperGrok subscription via a headless device-code flow (for VPS / SSH / Docker), or a pay-as-you-go API key from the xAI console.
|
||||
Two ways to authenticate: a SuperGrok subscription via device-code OAuth or a pay-as-you-go API key from the xAI console.
|
||||
|
||||
#### Option A — SuperGrok OAuth (browser login)
|
||||
#### Option A — SuperGrok subscription
|
||||
|
||||
1. Run the `/connect` command and search for **xAI**.
|
||||
|
||||
@@ -2318,9 +2318,11 @@ Three ways to authenticate: a SuperGrok subscription via browser OAuth, the same
|
||||
/connect
|
||||
```
|
||||
|
||||
2. Select **xAI Grok OAuth (SuperGrok Subscription)**. OpenCode opens xAI's consent screen in your browser and waits for the callback on `http://127.0.0.1:56121/callback`.
|
||||
2. Select **SuperGrok Subscription**. OpenCode opens xAI's verification link with the user code pre-populated when supported.
|
||||
|
||||
3. Run the `/models` command to select a Grok model.
|
||||
3. Approve the consent screen. If xAI asks for a code, enter the user code displayed by OpenCode. OpenCode polls xAI's token endpoint and stores the resulting OAuth tokens once you approve.
|
||||
|
||||
4. Run the `/models` command to select a Grok model.
|
||||
|
||||
```txt
|
||||
/models
|
||||
@@ -2328,25 +2330,7 @@ Three ways to authenticate: a SuperGrok subscription via browser OAuth, the same
|
||||
|
||||
OpenCode refreshes the OAuth access token automatically. Any Grok or X Premium plan that includes Grok API access works; you do not need a separate `XAI_API_KEY`.
|
||||
|
||||
#### Option B — SuperGrok device-code (headless / remote server / VPS)
|
||||
|
||||
Use this when OpenCode is running somewhere a browser can't reach the loopback redirect: a VPS, a remote dev box over SSH, inside Docker, in CI, etc. No callback port is opened on the host running OpenCode — instead xAI hands the CLI a short code that you type into a browser on any other device (laptop, phone, …).
|
||||
|
||||
1. Run the `/connect` command on the remote host and search for **xAI**.
|
||||
|
||||
```txt
|
||||
/connect
|
||||
```
|
||||
|
||||
2. Select **xAI Grok OAuth (Headless / Remote / VPS)**. OpenCode prints a verification URL and a short user code.
|
||||
|
||||
```txt
|
||||
Open https://x.ai/device on any device and enter code: ABCD-1234
|
||||
```
|
||||
|
||||
3. Open the URL on a device that has a browser (your laptop or phone), enter the code, and approve the consent screen. OpenCode polls xAI's token endpoint and stores the resulting OAuth tokens once you approve. Token refresh works the same as Option A.
|
||||
|
||||
#### Option C — API key
|
||||
#### Option B — API key
|
||||
|
||||
1. Head over to the [xAI console](https://console.x.ai/), create an account, and generate an API key.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user