# GitHub OAuth 앱 등록 가이드

## 1. Developer Settings 접속

1. https://github.com/settings/developers 접속
2. GitHub 계정 (또는 Organization owner 계정) 으로 로그인
3. 좌측 메뉴 → **OAuth Apps** → **New OAuth App**

## 2. 앱 정보 입력

- **Application name**: 예) "MCP Hub Integration"
- **Homepage URL**: `https://mcp-hub.wrks.ai`
- **Application description**: 사내 AI 에이전트가 GitHub 를 도구로 사용
- **Authorization callback URL**: `https://mcp-hub.wrks.ai/oauth/callback`

## 3. Client Secret 발급

- 생성 완료 후 앱 상세 화면
- **Client ID** 확인 (즉시 복사 가능)
- **Generate a new client secret** 클릭 → 생성된 값은 **최초 1회만 표시** — 즉시 복사

## 4. 조직 저장소 접근 승인 (조직 소유 저장소 사용 시)

개인 저장소만 접근하면 이 단계는 생략.
조직 저장소도 접근해야 한다면 owner 계정에서:

- `https://github.com/organizations/{org}/settings/oauth_application_policy`
- 등록한 OAuth App 을 **Approved** 상태로 변경
- Third-party access 정책이 'Restricted' 인 조직은 이 승인 없이는 API 호출이 실패함

## 5. Scope 선택

Studio 툴킷 설정 화면에서 요청할 scope:

- `repo` — 저장소 전체 접근 (private 포함)
- `read:org` — 조직 · 팀 조회
- `read:user` — 로그인 사용자 프로필
- `workflow` — GitHub Actions workflow 수정
- `notifications` — 알림 조회 · 관리

## 6. Studio 툴킷 설정

- Studio → Toolkits → New → 'GitHub' 템플릿 선택
- OAuth 설정 화면에 Client ID · Client Secret 입력
- 저장 후 사용자 로그인 시 위 scope 동의 화면이 뜸

## 참고

- Scope 전체 목록: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps
- 주의: `repo` scope 는 private repo 전체 (읽기 · 쓰기 · 관리) 접근 권한이므로 최소권한 원칙상 과할 수 있음. 세밀한 권한이 필요하면 **GitHub App (fine-grained permissions)** 방식이 있으며, 이는 v2 별도 템플릿으로 지원 예정.
