When you connect an AI coding environment to GitHub, you often see three different things that all look like "GitHub access": a Built-in Remote Connector, the gh CLI, and a GitHub MCP Server. On the surface they all touch your repositories. Under the hood, they represent three completely different identity boundaries, token lifecycles, and Non-Human Identity (NHI) risk profiles.

Three GitHub Integration Surfaces and Non-Human Identity
Figure 1: The three GitHub integration surfaces and their distinct identity and token boundaries (rendered with archify).

1. The Three Surfaces: Identity, AuthN, and AuthZ

2. Authorization Mechanics: AuthN vs AuthZ & NHI

Authentication (AuthN) proves who is making the request (human user vs. workload/agent). Authorization (AuthZ) decides what that identity is allowed to do on a specific resource. In agentic workflows, the agent acts as a Non-Human Identity (NHI)—either impersonating you (delegated OAuth/PAT) or acting as its own service principal (GitHub App installation token).

The core danger of conflating these surfaces is over-privileged delegation: giving an autonomous agent a classic gh CLI PAT with repo + admin:org scopes means a prompt injection or stray command has the exact same blast radius as you.

3. OAuth 2.1 & OIDC Federation Flows

Modern authorization replaces static, long-lived secrets with OAuth 2.1 (with mandatory PKCE) and OIDC Federation. Instead of storing a static PAT on disk, the client generates an ephemeral code_verifier, proves its identity to an Enterprise IdP via an OIDC ID Token, and exchanges the authorization code for a short-lived, narrowly scoped access token.

OAuth 2.1 PKCE and OIDC Federation Flow
Figure 2: OAuth 2.1 with PKCE and OIDC federation eliminating static long-lived secrets.

4. Enterprise Federation & Lifecycle Glue

In an enterprise environment, authentication is only half the story. Enterprise Federation & Lifecycle Glue connects your Identity Provider (Okta, Microsoft Entra ID) to GitHub via SCIM (for Joiner/Mover/Leaver provisioning) and an STS / Policy Gate (OPA) that issues Just-In-Time (JIT) ephemeral tokens. When a developer leaves or an agent task ends, access is revoked automatically without hunting down orphaned PATs.

Enterprise Federation and Lifecycle Glue
Figure 3: SCIM lifecycle provisioning paired with STS token exchange and OPA policy gates.

5. Cryptographic Authentication & Token Anatomy

Whether a token is an opaque GitHub PAT (ghp_... / github_pat_...) or a federated JWT, understanding its anatomy is essential for zero-trust verification:

Cryptographic Authentication and Token Anatomy
Figure 4: JWT cryptographic structure and zero-trust JWKS verification.

Summary

Use the Built-in Remote Connector for platform-managed repo cloning, gh CLI for interactive human terminal workflows, and a scoped GitHub MCP Server (backed by short-lived OAuth/App tokens) when giving AI agents structured, least-privilege access to your repositories.