Skip to content

fix(config): route GitHub App token refresh to enterprise API_URL#137

Open
Ahmadshata wants to merge 1 commit intogithubexporter:masterfrom
Ahmadshata:fix/ghes-github-app-installation-base-url
Open

fix(config): route GitHub App token refresh to enterprise API_URL#137
Ahmadshata wants to merge 1 commit intogithubexporter:masterfrom
Ahmadshata:fix/ghes-github-app-installation-base-url

Conversation

@Ahmadshata
Copy link

@Ahmadshata Ahmadshata commented Mar 19, 2026

Overview

This PR fixes GitHub App authentication for GitHub Enterprise environments by ensuring installation token refresh requests use the configured API_URL instead of defaulting to api.github.com.

Related Issues

Problem

When GITHUB_APP=true and API_URL points to GitHub Enterprise, API requests were correctly sent to the enterprise endpoint, but installation token refresh still targeted GitHub.com (/app/installations/{id}/access_tokens).
This caused authentication failures (401) in enterprise deployments.

Root Cause

ghinstallation.Transport was initialized, but its BaseURL was not overridden when a non-default API_URL was configured.

Changes

  • Updated GetClient() in config/config.go to set:
    • itr.BaseURL = c.ApiUrl.String() when API_URL is not https://api.github.com.
  • Added regression coverage in config/config_test.go:
    • New test verifies GitHub App transport BaseURL is set to enterprise API_URL.
    • Added a temporary private key test helper for GitHub App transport construction.

Validation

  • go test ./config
  • go test ./...

Impact

  • Fixes GitHub App installation token refresh for GitHub Enterprise users.
  • No behavior change for GitHub.com/default API_URL setups.
  • No API or config interface changes.

Risk

Low.
The change is narrowly scoped to transport initialization for GitHub App auth and is covered by targeted regression testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] GitHub App auth on GHES still uses api.github.com for installation token refresh instead of the configured API_URL

1 participant