AI / GitHub Copilot CLI Fundamentals Interview Questions
How do you authenticate GitHub Copilot CLI and what token types are supported?
Copilot CLI supports two authentication methods: an interactive browser-based flow (default) and a token-based flow for headless/automated environments.
| Method | How it works | Best for |
|---|---|---|
| Browser-based (default) | Run copilot or /login - browser opens for OAuth flow; token stored in system credential store | Interactive use on developer machines |
| Environment variable token | Set COPILOT_GITHUB_TOKEN, GH_TOKEN, or GITHUB_TOKEN env var | Headless automation, CI/CD, scripts |
# Method 1: Interactive browser flow (first time use) copilot # → prompted to /login if not authenticated # Follow on-screen browser authentication # Method 2: Fine-grained PAT in environment variable export COPILOT_GITHUB_TOKEN=github_pat_xxx copilot -p "List my open issues" # Method 3: Use GH_TOKEN or GITHUB_TOKEN (checked in order) export GH_TOKEN=your_token_here copilot -p "Explain this code"
Token type precedence (checked in order): COPILOT_GITHUB_TOKEN → GH_TOKEN → GITHUB_TOKEN.
Supported token types:
- Fine-grained personal access tokens (v2 PATs) with the Copilot Requests permission
- OAuth tokens from the Copilot CLI app
- OAuth tokens from the GitHub CLI (gh) app
- Classic personal access tokens (ghp_) are NOT supported
When no credential store is found, the token is saved as plain text in ~/.copilot/ (or the path set by COPILOT_HOME).
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
