Overview
OneCLI connects AI agents to GitHub so they can read and write code, open pull requests, manage issues, and trigger workflows. The gateway injects GitHub credentials into API requests automatically. OneCLI supports two ways to connect GitHub:What you will set up
- A GitHub connection through OAuth or a GitHub App
- Token injection on API calls and git-over-HTTPS
- Per-action allow, ask, or block controls for each agent
Quick example
An agent calling the GitHub API through the gateway, with no token management needed:Bearer token for API calls, Basic auth for git-over-HTTPS.
OAuth
Connect your personal GitHub account. The agent gets access to all repositories you can see.Setup
Go to Connections
Authorize

The GitHub connect window on OneCLI Cloud.
Self-hosted: use your own GitHub OAuth app
GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET set, or if you want your own company name on GitHub’s consent screen. For the GitHub App, see GitHub App self-hosted.1. Create the OAuth app
1. Create the OAuth app
OneCLI and enter your homepage URL.
The new OAuth app form, filled in.
2. Add the callback URL
2. Add the callback URL
repo, user, gist, notifications, project, codespace, and workflow when you connect.
Copy the Redirect URI from Custom credentials in OneCLI.
3. Connect with your app
3. Connect with your app
Permissions
The OAuth connection requests these scopes:More about OAuth: how it works, use cases, limitations
More about OAuth: how it works, use cases, limitations
- You authorize OneCLI via GitHub’s OAuth flow
- OneCLI receives a long-lived access token and encrypts it
- When an agent sends a request to
api.github.com, the gateway injects the token as aBearerheader - For git operations over HTTPS (
github.com), the gateway injects Basic auth credentials
- Coding agents creating branches, committing code, and opening pull requests
- Agents reviewing PRs and leaving comments
- Triggering GitHub Actions workflows from an agent
- Reading repository contents during code generation
- The token has access to all repositories you can see, not just selected ones
- No organizational visibility or approval flow
- Token is long-lived until you revoke the connection
GitHub App
For teams and organizations. A GitHub App gives you repo-level access control and organizational visibility. Org admins can see which repos are connected and approve or revoke access at any time.Setup
Go to Connections
Configure credentials (self-hosted only)
Install the app
- Select the organization or personal account
- Choose All repositories or Only select repositories
- Review the permissions
Permissions
The GitHub App requests only the permissions your agents need:More about the GitHub App: how it works, use cases
More about the GitHub App: how it works, use cases
- You install the GitHub App on your organization or account and select which repositories it can access
- OneCLI receives the app’s private key and installation ID
- The gateway signs a short-lived JWT and exchanges it for an installation access token (1hr TTL)
- The token is injected into API requests and automatically refreshed when it expires
- Organizations giving agents access to specific repos without exposing the full account
- Teams where admins need visibility into which repos agents can access
- Production deployments where token rotation should be automatic
- Compliance environments where long-lived tokens are not acceptable
Managing access
After connecting, you can change which repositories the app can access:- Go to Connections > GitHub App in the OneCLI dashboard
- Click Manage on the connection
- You’ll be taken to GitHub’s installation settings where you can add or remove repositories
Comparison
Per-action permissions
Once connected, the dashboard shows a permissions panel where you control what agents can do with GitHub. Each action has three modes: Allow (green), Ask (yellow, requires human approval), and Block (red, request is rejected). Read-only actions:Controlling access
Both connection methods are per agent: grant the connection to each agent that needs it, choosing per tool what runs freely, what needs human approval, and what stays blocked — a read-only agent is a single grant. Organization rules add guardrails on top:- Rate limit API calls to stay within GitHub’s rate limits
- Require manual approval for destructive operations (e.g., deleting branches)
- Scope a connection to specific repositories with a session policy
FAQ
How do I keep my GitHub token out of the agent's context?
How do I keep my GitHub token out of the agent's context?
GITHUB_TOKEN or store a token in the agent’s git config. Connect GitHub in OneCLI, and the gateway adds Bearer auth for API calls and Basic auth for git-over-HTTPS at the proxy. See How it works.OAuth or GitHub App?
OAuth or GitHub App?
How do I reconnect or replace the GitHub credential?
How do I reconnect or replace the GitHub credential?
Can I require approval before an agent merges or pushes?
Can I require approval before an agent merges or pushes?