Skip to content

Add interactive GitHub OAuth fallback for API_TOKEN - #14

Merged
michielbdejong merged 2 commits into
mainfrom
claude/issue-12-resolution-jogxis
Sep 7, 2026
Merged

michielbdejong merged 2 commits into
mainfrom
claude/issue-12-resolution-jogxis

Conversation

@michielbdejong

Copy link
Copy Markdown
Contributor

Summary

Closes #12.

  • Adds OAUTH_CLIENT_ID/OAUTH_CLIENT_SECRET (with GITHUB_CLIENT_ID/GITHUB_CLIENT_SECRET aliases, matching the existing API_TOKEN/GITHUB_TOKEN pattern) as an interactive fallback to the existing PAT-based auth.
  • src/oauth.rs: if API_TOKEN/GITHUB_TOKEN is present, it's checked against GET https://api.github.com/user and used as-is if GitHub still accepts it. Otherwise — if an OAuth App's client id/secret is configured — a small local axum web server walks the user through GitHub's authorization-code flow (a landing page with a "Sign in with GitHub" link, a /callback route that validates the CSRF state and exchanges the code for an access token) and the resulting token is used instead.
  • The whole fallback, including the PAT validity check, only runs when both OAuth variables are configured — a deployment that only sets API_TOKEN is completely unaffected, with zero extra network calls.
  • Updated README.md (configuration table + new "Authenticating with GitHub" section) and .env.example with the new variables.
  • Added CLAUDE.md (didn't exist yet) documenting the module map and project conventions.
  • Added a session log under docs/ai-logs/sessions/ per this repo's Generative AI disclosure policy.

Test plan

  • cargo fmt -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test — 37 passing, including new unit tests for resolve_oauth_settings and OAuth callback validation, plus an end-to-end test that binds the real local callback server and exercises the landing page and a forged-state callback (without reaching github.com)
  • cargo build

🤖 Generated with Claude Code

https://claude.ai/code/session_01CHYGjRjhdsemy2RwL5wBrT


Generated by Claude Code

Adds an OAuth client id/secret path for authenticating with GitHub
(issue #12): when API_TOKEN/GITHUB_TOKEN is missing or GitHub no longer
accepts it, and OAUTH_CLIENT_ID/OAUTH_CLIENT_SECRET are configured, a
small local web server walks the user through the authorization-code
flow to obtain a token. A deployment that only sets API_TOKEN is
unaffected — the whole fallback, including the PAT validity check, is
skipped when no OAuth settings are configured.

Also documents the new configuration in README.md and .env.example,
and adds CLAUDE.md for future AI-assisted sessions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CHYGjRjhdsemy2RwL5wBrT
…ution-jogxis

# Conflicts:
#	Cargo.toml
#	src/config.rs
#	src/main.rs
@michielbdejong
michielbdejong merged commit 8a2339c into main Sep 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

switch from PAT to OAuth

2 participants