Setup
Register a GitHub OAuth App at https://github.com/settings/developers and configure invigolium-configs.yaml:
GET /api/github/auth-url — Get OAuth Authorize URL
Returns the GitHub OAuth authorization URL. The frontend opens this in a popup window. Role: operatorGET /api/github/callback — OAuth Callback (Browser Redirect)
GitHub redirects the browser here after the user authorizes. This endpoint exchanges the code for an access token, stores the connection, and serves a small HTML page that closes the popup window. Role: public (no auth required — browser redirect from GitHub) Query parameters:| Parameter | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Authorization code from GitHub |
state | string | Yes | CSRF state parameter (must match) |
redirect_uri registered with the GitHub OAuth App.
POST /api/github/callback — Exchange OAuth Code (JSON API)
Alternative JSON endpoint for exchanging an OAuth code. Used when the frontend handles the code extraction from the popup. Role: operator Request body:| Field | Type | Required | Description |
|---|---|---|---|
code | string | Yes | Authorization code from GitHub |
state | string | Yes | CSRF state parameter |
GET /api/github/status — Connection Status
Returns whether the current user has a connected GitHub account for the active project. Role: operatorDELETE /api/github/disconnect — Disconnect GitHub
Removes the stored GitHub access token for the current user and project. Role: operatorGET /api/github/repos — List Repositories
Lists repositories accessible to the connected GitHub account. Proxied through the backend — the GitHub access token is never exposed to the frontend. Role: operator Query parameters:| Parameter | Type | Default | Description |
|---|---|---|---|
page | int | 1 | Page number |
per_page | int | 30 | Results per page (max 100) |
q | string | Search query (uses GitHub search API when set) |
GET /api/github/repos/:owner/:repo/branches — List Branches
Lists branches for a specific repository. Role: operator Path parameters:| Parameter | Type | Description |
|---|---|---|
owner | string | Repository owner |
repo | string | Repository name |
POST /api/github/repos/clone — Clone Repository
Clones a GitHub repository to local storage. The GitHub access token is injected into the clone URL for private repo access. Uses shallow clone with configurable depth fromsource_aware.clone_depth.
Role: operator
Request body:
| Field | Type | Required | Description |
|---|---|---|---|
clone_url | string | Yes | HTTPS clone URL from the repo listing |
branch | string | No | Branch to clone (defaults to repo’s default branch) |
hostname | string | No | If set, creates a source_repo record linking hostname |
path can be used as the source field in agent scan requests (swarm, pipeline, autopilot).
Error Responses
All endpoints return standard error JSON on failure:| Status | Meaning |
|---|---|
| 400 | Missing or invalid parameters, expired state |
| 401 | GitHub not connected (no stored token for user/project) |
| 502 | GitHub API error (token exchange failed, API unreachable) |
| 503 | GitHub integration not configured on the server |
Typical OAuth Flow
- Frontend calls
GET /api/github/auth-urlto get the authorize URL - Frontend opens the URL in a popup window
- User authorizes the app on GitHub
- GitHub redirects the popup to
GET /api/github/callback?code=X&state=Y - Backend exchanges the code for an access token, stores it, and serves HTML that closes the popup
- Frontend detects the popup closed and refetches
GET /api/github/status - User can now browse repos via
GET /api/github/reposand clone viaPOST /api/github/repos/clone
Database
GitHub connections are stored in thegithub_connections table, scoped by user_uuid + project_uuid (one connection per user per project). Access tokens are stored in the database and never exposed via the API (json:"-" tag).