{"record":{"id":"3f6d108c67059c8e","repo":"jdx/mise","slug":"github-oauth-is-configured-for-not","errorCode":null,"errorMessage":"GitHub OAuth is configured for {}, not {}","messagePattern":"GitHub OAuth is configured for (.+?), not (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/github/oauth.rs","lineNumber":241,"sourceCode":"        return Ok(None);\n    };\n    let access_token = refreshed.access_token.clone();\n    cache.tokens.insert(cache_key.to_string(), refreshed);\n    if let Err(err) = write_cache_locked_async(cache_lock, cache).await {\n        warn!(\"failed to cache refreshed GitHub OAuth token: {err:#}\");\n    }\n    Ok(Some(access_token))\n}\n\nasync fn token_async(req: TokenRequest) -> Result<String> {\n    let settings = Settings::get();\n    let client_id = settings.github.oauth_client_id.trim();\n    let scopes = settings.github.oauth_scopes.trim();\n    if client_id.is_empty() {\n        bail!(\"GitHub OAuth is not configured. Set github.oauth_client_id first.\");\n    }\n    if !host_matches_settings(&req.host, &settings.github.oauth_api_url) {\n        bail!(\n            \"GitHub OAuth is configured for {}, not {}\",\n            api_host(&settings.github.oauth_api_url).unwrap_or_else(|| \"unknown host\".to_string()),\n            req.host\n        );\n    }\n\n    let canonical_host =\n        api_host(&settings.github.oauth_api_url).unwrap_or_else(|| req.host.clone());\n    let cache_key = cache_key(&canonical_host, client_id, scopes);\n    let cache = read_cache_async().await?;\n    if !req.force_refresh\n        && let Some(cached) = cache.tokens.get(&cache_key)\n        && reusable(cached)\n    {\n        return Ok(cached.access_token.clone());\n    }\n    if let Some(cached) = cache.tokens.get(&cache_key).cloned() {\n        // Passing the cached token as \"stale\" forces the refresh-token grant","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/github/oauth.rs#L223-L259","documentation":"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).","triggerScenarios":"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`.","commonSituations":"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.","solutions":["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`","Check the request's host (`mise token github` argument or backend URL) and correct it to the configured host","Reset `github.oauth_api_url` to the default github.com if you intend to authenticate against public GitHub","Use per-project env config (`mise.toml`) to override the host per repository if you use both hosts"],"exampleFix":"// before: configured for github.com, requesting GHES token\n[github]\noauth_api_url = \"https://api.github.com\"\n// after\n[github]\noauth_api_url = \"https://github.mycompany.com/api/v3\"","handlingStrategy":"validation","validationCode":"mise settings get github.oauth_api_url  # must match the host you request tokens for","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep github.oauth_api_url and your remote/backend host consistent","For mixed github.com + GHES usage, scope host settings per project via mise.toml","After changing API host settings, re-authorize the OAuth token"],"tags":["github","oauth","host-mismatch","ghes"],"backgroundTag":"invalid-config-value","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}