Skip to content

feat(auth): implement GitHub token setup for private repos and higher rate limits#199

Merged
calchiwo merged 7 commits intomainfrom
feat/github-token-cli
Mar 24, 2026
Merged

feat(auth): implement GitHub token setup for private repos and higher rate limits#199
calchiwo merged 7 commits intomainfrom
feat/github-token-cli

Conversation

@calchiwo
Copy link
Owner

This PR introduces a config GitHub authentication flow using explainthisrepo init.

Before:

  • GitHub access relied on environment variables only
  • CLI exposed experimental --token flags
  • Private repos failed silently or with unclear errors
  • Rate limit errors were not actionable

After:

  • GitHub token can be configured once via init
  • Token is stored in config and automatically resolved
  • All GitHub calls use a unified auth pipeline
  • CLI no longer exposes --token flags
  • Errors now guide users to fix auth via init or env

Changes

  • init.py

    • prompt for optional GitHub token during setup
    • persist token under [github] config section
  • github.py

    • resolve token from:
      1. CLI override (future-safe)
      2. config file
      3. environment variables
    • attach token to all requests via shared session
    • improve rate limit and private repo error messages
  • repo_reader.py

    • propagate token through fetch_tree and fetch_file
    • ensure all repository reads use authenticated requests
  • cli.py

    • remove --token flags
    • add GitHub auth guidance to help output
    • surface token status in --doctor

Impact

  • enables access to private repositories
  • increases GitHub API rate limits when configured
  • improves UX by making auth setup explicit and centralized
  • removes inconsistent CLI-based auth paths

Notes

  • auth is optional; public repos continue to work without configuration
  • environment variables (GITHUB_TOKEN, GH_TOKEN) are still supported
  • this establishes a single source of truth for GitHub authentication

@calchiwo calchiwo added the python Pull requests that update python code label Mar 24, 2026
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explainthisrepo Ready Ready Preview, Comment Mar 24, 2026 4:04am

@calchiwo calchiwo merged commit 3244496 into main Mar 24, 2026
7 checks passed
calchiwo added a commit that referenced this pull request Mar 24, 2026
feat(auth): implement GitHub token setup for private repos and higher rate limits
@calchiwo
Copy link
Owner Author

See #157

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant