Skip to content

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

@Ahmadshata

Description

@Ahmadshata

Summary

When github-exporter is configured to use GitHub Enterprise Server (GHES) with GitHub App authentication, the exporter still tries to fetch the installation access token from https://api.github.com/app/installations/.../access_tokens instead of the configured GHES API URL.

This causes GitHub App auth to fail on GHES with 401 Unauthorized.

It looks like PR #131 fixed the regular client base URL handling, but the GitHub App installation transport still defaults to api.github.com.


Error

time="2026-03-19T03:57:50Z" level=error msg=" getting rate limit metrics: fetching rate limits: Get \"https://{GHES_DOMAIN}/api/v3/rate_limit?per_page=100\": could not refresh installation id 580's token: received non 2xx response status \"401 Unauthorized\" when fetching https://api.github.com/app/installations/580/access_tokens"

As shown above:

  • The exporter correctly calls the GHES rate limit endpoint:
https://{GHES_DOMAIN}/api/v3/rate_limit

But the GitHub App installation token refresh is still sent to:

https://api.github.com/app/installations/{INSTALLATION_ID}/access_tokens

Expected behavior

When API_URL is set to a GHES API endpoint, for example:

https://{GHES_DOMAIN}/api/v3

Then all GitHub App authentication calls should also use that same GHES base URL, including:

POST /app/installations/{INSTALLATION_ID}/access_tokens

So in this case, the request should go to:

https://{GHES_DOMAIN}/api/v3/app/installations/{INSTALLATION_ID}/access_tokens.

Why this matters

PR #131 fixed GHES support for the normal API client, but GHES + GitHub App auth still does not work because the installation token refresh path is still pointed at public GitHub.

So this seems to affect specifically:

  • API_URL set to GHES

  • GITHUB_APP=true

Environment

  • github-exporter version: v.2.3.0

  • Auth mode: GitHub App

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions