Native/CLI agent that authenticates via the Device Authorization Grant (RFC 8628), then uses Vouch's credential brokering API to obtain a GitHub installation token. Optionally clones a private repository using the brokered token.
The user authenticates by visiting a URL in their browser and entering a code. No client ID or secret is configured: the agent registers its own OAuth client with Vouch.
Vouch application type: none to create. The agent registers itself with RFC 7591 dynamic client registration, the same way the Vouch CLI does (see below for why a dashboard-created Native application cannot work).
Vouch's /v1/credentials/* endpoints only answer requests that carry an RFC 9421 HTTP Message Signature. Vouch looks up the verification key in the JWKS of the OAuth client the access token was issued to, and an application created in the dashboard as Native has no JWKS. So on first run the agent:
- Generates a P-256 key and registers a client at
POST /oauth/registerwith that key as an inline JWKS,token_endpoint_auth_method: private_key_jwt,dpop_bound_access_tokens: trueand thedevice_codegrant. - Saves the key and the registration to
$XDG_STATE_HOME/vouch-python-agent-github/client.json(mode0600) and reuses them on later runs.
- Device auth flow -- The agent requests a device code, authenticating with a
private_key_jwtclient assertion (RFC 7523), and displays a verification URL and user code. The user signs in via their browser. - Token -- The agent polls
/oauth/tokenwith a DPoP proof, retrying with the nonce Vouch asks for. The access token is DPoP-bound to the agent's key. - GitHub token -- The agent calls
POST /v1/credentials/github/tokenwithAuthorization: DPoP <token>, a DPoP proof bound to the token, aContent-Digestof the JSON body (RFC 9530), and an RFC 9421 signature covering@method,@authority,@path,@query,authorization,dpop,content-typeandcontent-digest. - Clone (optional) -- If
GITHUB_REPOis set, the agent clonesGITHUB_OWNER/GITHUB_REPOwith the brokered token. The token is passed togitas an HTTP header through the environment, so it appears neither in the process list nor in the clone's.git/config.
The access token must come from a hardware-key sign-in: Vouch refuses credential requests from sessions that did not verify the user's security key (hardware_required). The user's Vouch organization must have connected a GitHub account through the Vouch GitHub App.
| Variable | Required | Description |
|---|---|---|
VOUCH_ISSUER |
No | Vouch server URL (default: https://us.vouch.sh) |
GITHUB_OWNER |
When GITHUB_REPO is set, or when the organization has connected more than one GitHub account |
GitHub organization or user to get the token for |
GITHUB_REPOSITORIES |
No | Comma-separated repository names to scope the token to |
GITHUB_REPO |
No | Repository name to clone after obtaining the token |
XDG_STATE_HOME |
No | Where the registered client is kept (default ~/.local/state; /state in the Docker image) |
docker build -t vouch-python-agent-github .
docker run -it \
-v vouch-python-agent-github:/state \
-e VOUCH_ISSUER=https://us.vouch.sh \
-e GITHUB_OWNER=your-org \
vouch-python-agent-githubTo clone a private repository:
docker run -it \
-v vouch-python-agent-github:/state \
-e VOUCH_ISSUER=https://us.vouch.sh \
-e GITHUB_OWNER=your-org \
-e GITHUB_REPO=your-private-repo \
vouch-python-agent-githubThe named volume keeps the agent's key and client registration. Without it every run registers a new OAuth client with Vouch.