Learning resourcesReviewed · GitHub

Authenticating GitHub Copilot CLI

This GitHub guide explains Copilot CLI authentication for developers working locally or in automation, but environment tokens can silently override a saved login. It covers OAuth, token variables, GitHub CLI fallback, using your own model provider, offline limits and credential removal.

Researched 15 Nov 2026

In short.

This GitHub guide explains Copilot CLI sign-in for developers using terminals and automated systems, but using your own model provider without GitHub sign-in leaves several GitHub features unavailable. It documents browser and device-code OAuth, supported tokens, credential precedence, account switching and logout. Its most consequential details concern environment variables overriding saved credentials, possible plaintext token storage and offline mode still allowing requests to a remote model provider. Prices, installation requirements and compatibility with particular CLI versions are unknown from this page. No commands or authentication flows were executed or tested.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete supplied documentation page at [https://docs.github.com/api/article/body?pathname=/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli], including its BYOK, offline-mode, credential-precedence, storage and revocation notices. Linked pages are excluded. Installation, pricing, licensing, model quality and compatibility with particular releases are not established by this page. No commands, authentication flows, credential storage, network isolation or revocation behavior were executed or tested.

The overview

Identity

Authenticating GitHub Copilot CLI is GitHub documentation about signing into its command-line AI assistant. The resource is an authentication guide, with instructions for interactive terminals, automated environments and use with your own model provider.

The original source is [https://docs.github.com/api/article/body?pathname=/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli]. Its scope includes credentials and account management, rather than a complete introduction to Copilot CLI.

Assessment

The guide is useful when choosing a login method or investigating why Copilot CLI uses an unexpected account. It explains both the recommended methods and the precedence rules that can change which credential is used.

Its practical value is strongest around authentication configuration. It provides no evidence about coding quality, task completion, speed or reliability in a particular deployment.

Users

Local developers can follow the browser-based OAuth instructions. Developers using SSH, GitHub Codespaces, development containers or other headless environments get device-code instructions, while people configuring CI/CD receive guidance on token environment variables.

The page also addresses users managing multiple accounts, organizations using SAML SSO, and GitHub Enterprise Cloud instances with data residency. Beginners receive a step-by-step sign-in procedure; experienced developers get token types, credential precedence and provider-routing details.

Capabilities

The guide explains signing in through /login or copilot login, supplying tokens through environment variables, using an authenticated GitHub CLI as a fallback, and managing accounts through /user list and /user switch.

Using your own model provider API keys, called BYOK, allows model access without GitHub authentication. Without GitHub authentication, /delegate, the GitHub MCP server and GitHub Code Search are unavailable. BYOK can also be combined with GitHub authentication to retain GitHub-hosted features.

Using it

Requirements

GitHub authentication is required unless Copilot CLI uses your own model provider keys. Supported GitHub credentials include OAuth tokens with the gho_ prefix, fine-grained personal access tokens with github_pat_, and GitHub App user-to-server tokens with ghu_. Classic personal access tokens with ghp_ are unsupported.

A fine-grained personal access token must belong to your personal account and include the Copilot Requests account permission. GitHub App user-to-server tokens are supplied through an environment variable. OAuth authorization requires a browser, including when initiated through a device code.

Installation steps, minimum CLI versions, complete system requirements and subscription entitlement requirements are not specified on this page.

Mechanism

Credential lookup proceeds through COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN, the stored OAuth token and finally gh auth token. An environment variable can therefore override a saved login without prompting. In Codespaces, the automatically injected GITHUB_TOKEN does not override an account signed in through /login; explicitly exported supported token variables still do.

OAuth tokens normally use the operating system keychain under the service name copilot-cli: Keychain Access on macOS, Credential Manager on Windows and libsecret-backed storage on Linux. If the keychain is unavailable, the CLI prompts about storing the token in plaintext at ~/.copilot/config.json.

Configured BYOK provider variables control AI model requests regardless of GitHub authentication status. GitHub credentials remain relevant to GitHub-hosted features.

Setup

For interactive use, run copilot login in a terminal or /login inside Copilot CLI and complete authorization. Local desktops default to a browser flow with a local callback; known remote or headless environments default to device codes. The options --web-flow and --device-code force the corresponding flow.

For GitHub Enterprise Cloud with data residency, use copilot login --host HOSTNAME or enter the instance hostname through /login. Authorize relevant SAML SSO organizations when prompted and review the requested permissions.

For automation, create a personal-account fine-grained token, choose appropriate repository access, enable the Copilot Requests account permission and supply it through a supported environment variable. For GitHub CLI fallback, first check gh auth status, using --hostname HOSTNAME when appropriate.

Example

For a headless-server example, run copilot login --device-code. Open [https://github.com/login/device] in a browser, enter the one-time code displayed by your terminal and approve the requested access. Then start copilot and use /user to inspect the authenticated account.

This is an illustrative sequence based on the documentation, not an executed session. An exported token variable can still take precedence over the saved OAuth credential.

Assessment & evidence

Limitations

Setting COPILOT_OFFLINE=true disables GitHub contact, GitHub authentication attempts and telemetry, but requests still go to the configured BYOK provider. Full network isolation requires that provider to be local or within the isolated environment. A remote COPILOT_PROVIDER_BASE_URL still receives prompts and code context. BYOK without offline mode still sends telemetry normally.

Token lifetime depends on how the token was created and on account or organization settings; no universal expiration period is given. Running /logout removes the locally stored token but does not revoke it on GitHub. Plaintext storage may be offered when the system keychain is unavailable.

Reasoning

Based on the documented behavior, the useful decision points are whether a person can complete browser authorization, whether the process must run unattended, whether GitHub-hosted features are needed and where model requests may travel. These considerations explain the guide's recommendations of OAuth for interactive work and token variables for automation.

The separation between provider configuration and GitHub authentication means a working model connection does not establish access to GitHub features. Likewise, selecting offline mode alone does not establish that prompts remain inside an isolated environment.

Alternatives

The alternatives documented here are authentication approaches within Copilot CLI. Browser OAuth suits a local interactive session; device-code OAuth supports remote sessions; environment tokens support unattended operation; authenticated GitHub CLI provides a lower-priority fallback.

BYOK is another route for model requests and can operate without GitHub sign-in, subject to the feature restrictions described above. The page does not compare competing coding assistants or other authentication guides.

Evidence

The evidence consists of the complete supplied GitHub authentication page. It directly supports the descriptions of login flows, supported credentials, account management, provider-key operation and offline-mode behavior.

Commands and success messages on the page are documentation examples. No execution results, independent measurements or observed authentication sessions are supplied. Linked troubleshooting and other documentation pages are outside the available evidence.

Access & freshness

Costs

The page supplies no subscription prices, included request allowances, overage charges or model-provider prices. Costs are unknown from this evidence. BYOK removing the need for GitHub authentication does not establish that model requests are free.

Rights

The supplied page does not establish a redistribution license for its text, Copilot CLI usage terms, model-provider terms or generated-output rights. Those rights remain unknown from this evidence. The documented authentication permissions do not establish permission to redistribute documentation or software.

Freshness

The supplied page was captured on 15 November 2026 at 12:39:22.194 UTC. Its text provides no publication date, last-updated date or specific Copilot CLI version requirement.

The capture establishes what this page stated at that time. When individual behaviors were introduced, and whether they apply to a particular installed release, remain unknown.

Actions

Choose the documented method that matches your environment, inspect supported token variables for unintended overrides and use /user to check the account Copilot CLI reports. If keychain storage is unavailable, consider the implications before accepting the offered plaintext storage.

For BYOK, decide whether GitHub-hosted features are required and check the provider endpoint before treating offline mode as network isolation. To remove a saved login, use /logout; to revoke the OAuth authorization on GitHub, use Settings > Applications > Authorized OAuth Apps and revoke GitHub Copilot CLI.

Evidence for this report

selected-page.txtselected · checked 2026-11-15