Sycophant.Auth.GithubCopilot.Exchange (sycophant v0.4.2)

Copy Markdown

Performs the GitHub->Copilot token exchange.

This is a reverse-engineered, undocumented endpoint. See the design doc at docs/superpowers/specs/2026-05-05-github-copilot-provider-design.md for caveats.

Summary

Functions

Exchanges a GitHub OAuth token / PAT for a short-lived Copilot token.

Functions

exchange(github_host, github_token)

@spec exchange(String.t(), String.t()) :: {:ok, map()} | {:error, Splode.Error.t()}

Exchanges a GitHub OAuth token / PAT for a short-lived Copilot token.

github_host defaults to "github.com". For GitHub Enterprise Server, pass the Enterprise host (e.g. "github.example.com"); the URL is then constructed as https://{host}/api/v3/copilot_internal/v2/token.

Returns {:ok, entry} on success, where entry is a map with :copilot_token, :expires_at (DateTime), :endpoints, and :fetched_at keys. Returns {:error, splode_error} otherwise.