BerriAI/litellm · error · XAIOAuthLoginRequiredError
xAI OAuth refresh token missing. Run `litellm xai-oauth logi
Error message
xAI OAuth refresh token missing. Run `litellm xai-oauth login`.
What it means
Same login-required error as the access-token path, but fired when the auth record exists and has no refresh_token: the token cannot be refreshed, so re-authentication via `litellm xai-oauth login` is the only recovery.
Source
Thrown at litellm/llms/xai/oauth.py:107
self.token_dir = get_secret_str("XAI_OAUTH_TOKEN_DIR") or os.path.expanduser("~/.config/litellm/xai_oauth")
self.auth_file = os.path.join(self.token_dir, get_secret_str("XAI_OAUTH_AUTH_FILE") or "auth.json")
self.http_client = http_client
def get_api_base(self) -> str:
return get_secret_str("XAI_OAUTH_API_BASE") or get_secret_str("XAI_API_BASE") or XAI_API_BASE
def get_access_token(self) -> str:
auth_data: Final = self._read_auth_file()
if not auth_data:
raise XAIOAuthLoginRequiredError("xAI OAuth login required. Run `litellm xai-oauth login`.")
access_token = auth_data.get("access_token")
if access_token and not self._is_expired(auth_data):
return access_token
refresh_token: Final = auth_data.get("refresh_token")
if not refresh_token:
raise XAIOAuthLoginRequiredError("xAI OAuth refresh token missing. Run `litellm xai-oauth login`.")
with _XAI_OAUTH_REFRESH_LOCK:
locked_auth_data: Final = self._read_auth_file() or auth_data
access_token = locked_auth_data.get("access_token")
if access_token and not self._is_expired(locked_auth_data):
return access_token
refreshed: Final = self._refresh_tokens(locked_auth_data)
return refreshed["access_token"]
def login(self, force: bool = False, no_browser: bool = False) -> dict[str, Any]:
existing: Final = self._read_auth_file()
if existing and not force and existing.get("access_token"):
if not self._is_expired(existing):
return existing
if existing.get("refresh_token"):
try:
return self._refresh_tokens(existing)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Run `litellm xai-oauth login` again to obtain and store a fresh refresh token.
- Check that the token storage location is readable and was not cleared.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at litellm/llms/xai/oauth.py:107 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/213cfb42bc3f6173.
Report an issue: GitHub.