jdx/mise · error

GitHub OAuth is configured for

Error message

GitHub OAuth is configured for {}, not {}

What it means

mise's GitHub OAuth can be pointed at a GitHub Enterprise host via `github.oauth_api_url`. `token_async` validates that the requested token's host matches the configured API host; a token request for a different host is rejected rather than silently issuing a github.com token for an enterprise host (or vice versa).

Solutions

  1. Set `github.oauth_api_url` to match the host you're authenticating against: `mise settings set github.oauth_api_url https://github.mycompany.com/api/v3`
  2. Check the request's host (`mise token github` argument or backend URL) and correct it to the configured host
  3. Reset `github.oauth_api_url` to the default github.com if you intend to authenticate against public GitHub
  4. Use per-project env config (`mise.toml`) to override the host per repository if you use both hosts

Example fix

// before: configured for github.com, requesting GHES token
[github]
oauth_api_url = "https://api.github.com"
// after
[github]
oauth_api_url = "https://github.mycompany.com/api/v3"
Defensive patterns

Strategy: validation

Validate before calling

mise settings get github.oauth_api_url  # must match the host you request tokens for

Prevention

When it happens

Trigger: Requesting a token for host X (e.g. `github.mycompany.com`) while `github.oauth_api_url` is configured for `github.com` (or another enterprise host), via `mise token github` or any backend call reaching `token_async`.

Common situations: Mixed GHES + github.com usage with a single global oauth_api_url; leftover oauth_api_url from a previous enterprise setup; backend configured with an enterprise URL while OAuth was set up for github.com.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/3f6d108c67059c8e. Report an issue: GitHub.

Appendix: source

Thrown at src/github/oauth.rs:241

        return Ok(None);
    };
    let access_token = refreshed.access_token.clone();
    cache.tokens.insert(cache_key.to_string(), refreshed);
    if let Err(err) = write_cache_locked_async(cache_lock, cache).await {
        warn!("failed to cache refreshed GitHub OAuth token: {err:#}");
    }
    Ok(Some(access_token))
}

async fn token_async(req: TokenRequest) -> Result<String> {
    let settings = Settings::get();
    let client_id = settings.github.oauth_client_id.trim();
    let scopes = settings.github.oauth_scopes.trim();
    if client_id.is_empty() {
        bail!("GitHub OAuth is not configured. Set github.oauth_client_id first.");
    }
    if !host_matches_settings(&req.host, &settings.github.oauth_api_url) {
        bail!(
            "GitHub OAuth is configured for {}, not {}",
            api_host(&settings.github.oauth_api_url).unwrap_or_else(|| "unknown host".to_string()),
            req.host
        );
    }

    let canonical_host =
        api_host(&settings.github.oauth_api_url).unwrap_or_else(|| req.host.clone());
    let cache_key = cache_key(&canonical_host, client_id, scopes);
    let cache = read_cache_async().await?;
    if !req.force_refresh
        && let Some(cached) = cache.tokens.get(&cache_key)
        && reusable(cached)
    {
        return Ok(cached.access_token.clone());
    }
    if let Some(cached) = cache.tokens.get(&cache_key).cloned() {
        // Passing the cached token as "stale" forces the refresh-token grant

View on GitHub (pinned to 533346cc37)