docs: Gmail Calendar scope 재연동 가이드
- auth-server에 Calendar scope 추가 방법 - 사용자별 재인증 절차 - E2E 테스트 시나리오 - 트러블슈팅 가이드
This commit is contained in:
parent
beae8d30b3
commit
be7923b5f0
175
troubleshooting/251114_gmail_calendar_scope_reconnect_guide.md
Normal file
175
troubleshooting/251114_gmail_calendar_scope_reconnect_guide.md
Normal file
@ -0,0 +1,175 @@
|
||||
# Gmail Passport Calendar Scope 재연동 가이드
|
||||
|
||||
**작성일**: 2025-11-14
|
||||
**작성자**: Claude
|
||||
**목적**: skill-calendar를 위한 Google Calendar API scope 추가
|
||||
|
||||
---
|
||||
|
||||
## 1. 현재 상황
|
||||
|
||||
### 문제
|
||||
- skill-calendar가 gmail_token 조회는 성공
|
||||
- Google Calendar API 호출 시 `invalid_grant` 에러 발생
|
||||
- 원인: 현재 Gmail Passport scope에 Calendar API 권한 없음
|
||||
|
||||
### 필요한 Scope
|
||||
```python
|
||||
# 기존 (auth-server/app/providers/gmail_passport.py)
|
||||
GMAIL_API_SCOPES = [
|
||||
"https://www.googleapis.com/auth/gmail.send",
|
||||
"https://www.googleapis.com/auth/gmail.readonly",
|
||||
"https://www.googleapis.com/auth/gmail.modify",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile"
|
||||
]
|
||||
|
||||
# 추가 필요
|
||||
+ "https://www.googleapis.com/auth/calendar",
|
||||
+ "https://www.googleapis.com/auth/calendar.events"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. 재연동 방법
|
||||
|
||||
### 방법 1: auth-server scope 수정 후 재인증 (권장)
|
||||
|
||||
#### Step 1: auth-server scope 수정
|
||||
```bash
|
||||
# 51123 서버 접속 (auth-server는 51123에서 실행)
|
||||
ssh admin@192.168.219.45
|
||||
|
||||
# auth-server 디렉토리로 이동
|
||||
cd /home/admin/auth-server
|
||||
|
||||
# gmail_passport.py 수정
|
||||
vi app/providers/gmail_passport.py
|
||||
```
|
||||
|
||||
**수정 내용**:
|
||||
```python
|
||||
# Line 찾아서 수정 (대략 30-40줄)
|
||||
GMAIL_API_SCOPES = [
|
||||
"https://www.googleapis.com/auth/gmail.send",
|
||||
"https://www.googleapis.com/auth/gmail.readonly",
|
||||
"https://www.googleapis.com/auth/gmail.modify",
|
||||
"https://www.googleapis.com/auth/userinfo.email",
|
||||
"https://www.googleapis.com/auth/userinfo.profile",
|
||||
"https://www.googleapis.com/auth/calendar", # 추가
|
||||
"https://www.googleapis.com/auth/calendar.events" # 추가
|
||||
]
|
||||
```
|
||||
|
||||
#### Step 2: auth-server 재배포
|
||||
```bash
|
||||
# Git 커밋
|
||||
git add app/providers/gmail_passport.py
|
||||
git commit -m "feat: Gmail Passport에 Calendar scope 추가"
|
||||
git push origin main
|
||||
|
||||
# Gitea Actions가 자동 배포 (30초 소요)
|
||||
# 또는 수동 배포:
|
||||
docker compose restart
|
||||
```
|
||||
|
||||
#### Step 3: 사용자별 재인증
|
||||
|
||||
**웹 브라우저에서**:
|
||||
1. https://ro-being.com 로그인 (김종태 계정)
|
||||
2. 설정 > 아이템 > Gmail
|
||||
3. "재인증" 버튼 클릭
|
||||
4. Google 권한 동의 화면에서 Calendar 권한 확인
|
||||
5. "허용" 클릭
|
||||
6. 자동으로 인벤토리 페이지로 리다이렉트
|
||||
7. gmail_token 테이블에 새로운 scope 저장됨
|
||||
|
||||
**확인**:
|
||||
```bash
|
||||
# 51124 서버에서
|
||||
cd /home/admin/ivada_project/skill-calendar
|
||||
python3 tests/test_google_calendar_integration.py
|
||||
```
|
||||
|
||||
### 방법 2: DB 직접 수정 (비권장, 임시)
|
||||
|
||||
#### 주의
|
||||
- OAuth 토큰은 발급 시 scope가 고정됨
|
||||
- DB만 수정해도 Google API는 scope 부족으로 거부
|
||||
- 반드시 재인증 필요
|
||||
|
||||
#### 확인용 쿼리
|
||||
```sql
|
||||
-- 현재 scope 확인
|
||||
SELECT user_id, scopes FROM gmail_token
|
||||
WHERE user_id = '53529291-5050-4daa-89fb-008b546feb63';
|
||||
|
||||
-- scope 추가 (효과 없음, 재인증 필요)
|
||||
UPDATE gmail_token
|
||||
SET scopes = scopes || '["https://www.googleapis.com/auth/calendar"]'::jsonb
|
||||
WHERE user_id = '53529291-5050-4daa-89fb-008b546feb63';
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Google Cloud Console 설정 확인
|
||||
|
||||
### OAuth 동의 화면
|
||||
1. https://console.cloud.google.com/apis/credentials
|
||||
2. OAuth 2.0 클라이언트 ID 선택
|
||||
3. "OAuth 동의 화면" 탭
|
||||
4. "범위" 섹션에서 Calendar API 추가 확인
|
||||
- `.../auth/calendar` - 캘린더 전체 권한
|
||||
- `.../auth/calendar.events` - 일정 읽기/쓰기
|
||||
|
||||
### API 활성화
|
||||
1. "API 및 서비스" > "라이브러리"
|
||||
2. "Google Calendar API" 검색
|
||||
3. "사용 설정" 클릭 (이미 활성화되어 있을 수 있음)
|
||||
|
||||
---
|
||||
|
||||
## 4. 테스트 시나리오
|
||||
|
||||
### E2E 테스트
|
||||
```
|
||||
1. auth-server scope 수정 완료
|
||||
2. 김종태 계정 Gmail 재인증
|
||||
3. ro-being.com 로그인
|
||||
4. 로빙에게 메시지: "11월 24일 검진 07:40~12시 인천 연수구 갯벌로156"
|
||||
5. 로빙 응답: "일정을 구글 캘린더에 등록해드릴까요?"
|
||||
6. 사용자 응답: "그래"
|
||||
7. 로빙 응답: "✅ 구글 캘린더에 일정을 등록했습니다!"
|
||||
8. Google Calendar 웹에서 확인: 2025-11-24 07:40~12:00 일정 존재
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. 트러블슈팅
|
||||
|
||||
### invalid_grant 계속 발생
|
||||
- Gmail Passport 재인증 확인
|
||||
- gmail_token.scopes 필드에 calendar 포함 확인
|
||||
- access_token 갱신 시도 (refresh_token 사용)
|
||||
|
||||
### Calendar API 403 Forbidden
|
||||
- Google Cloud Console에서 Calendar API 활성화 확인
|
||||
- OAuth 동의 화면에 Calendar scope 추가 확인
|
||||
|
||||
### 일정 등록 성공했지만 Calendar에 없음
|
||||
- 다른 Google 계정으로 로그인했을 가능성
|
||||
- primary calendar 대신 다른 캘린더 ID 사용 여부 확인
|
||||
|
||||
---
|
||||
|
||||
## 6. 참고 문서
|
||||
|
||||
- DOCS/troubleshooting/250820_happybell80_Gmail패스포트시스템완성.md
|
||||
- DOCS/plans/251114_skill_calendar_multiplatform_integration.md
|
||||
- Google Calendar API: https://developers.google.com/calendar/api/guides/overview
|
||||
|
||||
---
|
||||
|
||||
**작업 완료**: 문서 작성
|
||||
**다음 단계**: auth-server scope 수정 → 사용자 재인증
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user