jdx/mise · error
GitHub OAuth token is not cached. Run `mise token github…
Error message
GitHub OAuth token is not cached. Run `mise token github --oauth` to authorize.
What it means
GitHub OAuth tokens issued by the device flow are cached with an expiry. When a non-forced token request finds no cached token (or an expired one) and the caller did not allow the interactive device flow, mise fails with instructions to authorize first instead of hanging on an interactive prompt.
Solutions
- Run `mise token github --oauth` once interactively to complete the device flow and cache a token
- In CI, provide a PAT via `GITHUB_TOKEN`/`MISE_GITHUB_TOKEN` instead of relying on the OAuth cache
- If a token was authorized before, check that the cache file is readable and HOME is the same user
- Use force_refresh via `mise token github --force` only after confirming the client id and host config are correct
Example fix
// before (non-interactive CI) mise token github // after: authorize once locally, or use a PAT in CI export GITHUB_TOKEN=ghp_xxx # or run `mise token github --oauth` locally
Defensive patterns
Strategy: fallback
Validate before calling
test -n "$GITHUB_TOKEN" || mise token github --oauth # ensure a token source exists before non-interactive use
Try / catch
// run authorize flow on missing-token, then retry
if let Err(e) = get_token(false).await {
if e.to_string().contains("not cached") {
get_token(/* allow_device_flow */ true).await?;
} else { return Err(e); }
} Prevention
- Run `mise token github --oauth` once on each machine before scripted use
- Provide GITHUB_TOKEN/MISE_GITHUB_TOKEN in CI instead of the device flow
- Re-authorize after cache clears or long expiry gaps
When it happens
Trigger: Calling `mise token github` without `--oauth` (or `token_async` with `allow_device_flow=false`) when no valid cached token exists — first use, expired token, or cache cleared.
Common situations: CI/non-interactive environments where device flow can't run; token cache wiped (new HOME, `mise cache clear`); token expired after 8 hours; running a different command that needs the token without having authorized once.
Related errors
- {details}
- GitHub device authorization expired
- GitHub device authorization was denied
- GitHub OAuth is configured for
- GitHub OAuth is not configured. Set github.oauth_client_id…
AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17).
Data as JSON: /api/errors/c86663002d8a3b33.
Report an issue: GitHub.
Appendix: source
Thrown at src/github/oauth.rs:278
// even though the token is still time-valid.
let stale_access_token = req.force_refresh.then_some(cached.access_token.as_str());
match refresh_cached_token(&cache_key, stale_access_token).await {
Ok(Some(token)) => return Ok(token),
Ok(None) => {}
Err(err) => {
if req.warn_on_refresh_failure {
log_refresh_error(&err);
} else {
debug!("failed to refresh GitHub OAuth token for environment export: {err:#}");
}
}
}
if !req.force_refresh && cached.expires_at > chrono::Utc::now() {
return Ok(cached.access_token);
}
}
if !req.allow_device_flow {
bail!("GitHub OAuth token is not cached. Run `mise token github --oauth` to authorize.");
}
let device = create_device_code().await?;
print_device_instructions(&device);
let token = poll_access_token(&device).await?;
let cached = token_response_to_cache(token)?;
let access_token = cached.access_token.clone();
if let Err(err) = cache_token(cache_key, cached).await {
warn!("failed to cache GitHub OAuth token: {err:#}");
}
Ok(access_token)
}
async fn create_device_code() -> Result<DeviceCodeResponse> {
let settings = Settings::get();
let url = format!(
"{}/device/code",
settings.github.oauth_auth_url.trim_end_matches('/')View on GitHub (pinned to 533346cc37)