Hmbown/CodeWhale · error · anyhow::Error
xAI OAuth credentials not found. Options: 1. Run `codewhale…
Error message
xAI OAuth credentials not found.
Options:
1. Run `codewhale auth xai-device` for Codewhale-owned OAuth storage
2. To read an existing Grok CLI login without changing it, run `codewhale auth external-consent --provider xai --mode read-only --path {}`
3. Or use API-key auth: export XAI_API_KEY=... / codewhale auth set --provider xai What it means
When the xAI route is in OAuth mode - either [providers.xai] auth_mode = "oauth" or Grok CLI tokens already exist on disk - and no OAuth credential is usable, the Xai arm bails with xai_oauth::missing_auth_message() (crates/tui/src/xai_oauth.rs:776). The message offers the three supported paths: Codewhale-owned device OAuth, read-only import of an existing Grok CLI login, or plain API-key auth.
Solutions
- Run 'codewhale auth xai-device' to complete device-login into Codewhale-owned OAuth storage
- To reuse an existing Grok CLI login read-only: codewhale auth external-consent --provider xai --mode read-only --path <grok-auth-file>
- Or drop OAuth: remove auth_mode = "oauth" from [providers.xai] and use export XAI_API_KEY=... / codewhale auth set --provider xai
Example fix
# before [providers.xai] auth_mode = "oauth" # after $ codewhale auth xai-device # completes device login [providers.xai] auth_mode = "oauth"
Defensive patterns
Strategy: try-catch
Validate before calling
if provider == ApiProvider::Xai
&& route.auth_mode.as_deref() == Some("oauth")
&& !xai_owned_token_present()
&& !xai_read_only_grant_present()
{
eprintln!("complete 'codewhale auth xai-device' or grant read-only consent before launch");
} Type guard
fn xai_oauth_ready(auth_mode_oauth: bool, owned: bool, grant: bool) -> bool {
!auth_mode_oauth || owned || grant
} Try / catch
match config.deepseek_api_key() {
Err(e) if e.to_string().starts_with("xAI OAuth credentials not found") => {
// offer the three options verbatim: xai-device, external-consent read-only, or API key
}
other => other?,
} Prevention
- Finish 'codewhale auth xai-device' before setting auth_mode = "oauth" in [providers.xai]
- Existing Grok CLI logins only work through an explicit read-only consent grant with --path
- If you do not want OAuth, remove auth_mode = "oauth" so the plain API-key path applies
When it happens
Trigger: provider == ApiProvider::Xai with provider_config_uses_xai_oauth true or xai_oauth::credentials_present(self) true, and the owned OAuth store plus consent grants yield nothing. The first bail inside the Xai arm fires with the xai_oauth message.
Common situations: Setting auth_mode = "oauth" but never completing 'codewhale auth xai-device'; a partial Grok CLI login file; switching machines and losing the owned OAuth storage while the config still says oauth.
Related errors
- xAI OAuth credentials at
- agy OAuth token JSON carries no access token member
- agy OAuth token member
- atomically replacing xAI OAuth credentials
- bearer credentials are not an API key
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/92ca64539da91854.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/config.rs:6724
provider_config_table_name(provider)?
);
}
ApiProvider::Anthropic | ApiProvider::Openmodel => {
anyhow::bail!("{}", missing_provider_api_key_message(provider)?)
}
ApiProvider::OpencodeZen => {
anyhow::bail!("{}", missing_provider_api_key_message(provider)?)
}
ApiProvider::OpenaiCodex => anyhow::bail!("{}", crate::oauth::missing_auth_message()),
ApiProvider::Xai => {
// Prefer OAuth guidance when auth_mode requests it or Grok CLI
// tokens already exist; otherwise show both API-key and OAuth.
if self
.provider_config_for(provider)
.is_some_and(provider_config_uses_xai_oauth)
|| crate::xai_oauth::credentials_present(self)
{
anyhow::bail!("{}", crate::xai_oauth::missing_auth_message());
}
anyhow::bail!(
"xAI API key not found. Get a key: https://console.x.ai/\n\
Run 'codewhale auth set --provider xai', set XAI_API_KEY, or add \
[providers.xai] api_key.\n\
OAuth alternative: run `codewhale auth xai-device` for \
Codewhale-owned storage and set [providers.xai] auth_mode = \"oauth\"."
);
}
// Self-hosted deployments commonly run without auth on localhost.
// Return an empty key and let the client omit the Authorization header.
ApiProvider::Sglang | ApiProvider::Vllm => Ok(String::new()),
ApiProvider::Ollama
if provider_route_is_keyless_self_hosted(provider, &self.deepseek_base_url()) =>
{
Ok(String::new())
}
ApiProvider::Ollama => {View on GitHub (pinned to 0c42157ee5)