시작하기

인증

IVGraph는 두 가지 인증 방식을 사용해요. 노션 OAuth를 이용하는 웹 사용자용 JWT 토큰과 LLM 에이전트 및 자동화용 서비스 토큰이에요.

노션 OAuth (JWT)

IVGraph는 노션의 OAuth2 인증 흐름을 통해 사용자를 인증해요. 사용자 이름과 비밀번호로 가입하는 방식은 없어요.

인증 흐름

User clicks "Sign in with Notion"
        |
        v
GET /api/integrations/auth/notion/
        |  -> Redirects to Notion consent screen
        v
User authorizes IVGraph in Notion
        |
        v
Notion redirects to /api/integrations/auth/notion/callback?code=...
        |  -> Backend exchanges code for Notion token
        |  -> Creates/updates Django user
        |  -> Issues JWT tokens
        v
Redirect to dashboard with tokens in URL fragment

JWT 토큰

토큰 유효 기간 용도
액세스 토큰 4시간 API 인증
리프레시 토큰 7일 새 액세스 토큰 발급

액세스 토큰 사용:

curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
  "https://ivgraph.com/api/notion-graph/"

만료된 토큰 갱신:

curl -X POST "https://ivgraph.com/api/auth/refresh/" \
  -H "Content-Type: application/json" \
  -d '{"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."}'

응답:

{"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."}

로그아웃 (리프레시 토큰을 차단 목록에 추가):

curl -X POST "https://ivgraph.com/api/auth/logout/" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{"refresh": "<refresh_token>"}'

인증 엔드포인트

메서드 엔드포인트 설명
GET /api/integrations/auth/notion/ 노션 OAuth 흐름 시작
GET /api/integrations/auth/notion/callback OAuth 콜백 (내부용)
GET /api/integrations/auth/notion/status OAuth 상태 확인
POST /api/auth/refresh/ 액세스 토큰 갱신
POST /api/auth/logout/ 리프레시 토큰을 차단 목록에 추가
GET /api/auth/validate/ 토큰 유효성 확인
GET /api/auth/me/ 현재 사용자 정보 조회

서비스 토큰 (LLM 에이전트용)

서비스 토큰은 지정된 권한 범위 내에서 V1 읽기 전용 API에 장기간 접근할 수 있는 권한을 제공해요. LLM 에이전트, 자동화 스크립트, CI/CD 파이프라인을 위해 설계되었어요.

토큰 형식

  • 접두사: ivg_ (예: ivg_a1b2c3d4e5f6...)
  • 길이: 접두사 뒤에 무작위 문자 32개
  • 저장 방식: 데이터베이스에는 SHA-256 해시만 저장되며, 원본 토큰은 생성 시 한 번만 표시돼요

토큰 생성

API로 생성 (JWT 인증 필요):

curl -X POST "https://ivgraph.com/api/tokens/" \
  -H "Authorization: Bearer <jwt_access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My LLM Agent",
    "scopes": ["graph:search", "graph:read", "graph:neighbors"],
    "workspace_ids": ["your-workspace-uuid"],
    "expires_in_days": 90
  }'

응답 (토큰은 한 번만 표시돼요!):

{
  "id": 1,
  "name": "My LLM Agent",
  "token": "ivg_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
  "prefix": "ivg_a1b2c3",
  "scopes": ["graph:search", "graph:read", "graph:neighbors"],
  "workspace_ids": ["your-workspace-uuid"],
  "is_active": true,
  "created_at": "2026-04-10T12:00:00Z",
  "expires_at": "2026-07-09T12:00:00Z"
}

권한 범위

권한 범위 허용 작업
graph:search 제목으로 노드 검색
graph:read 노드 상세 정보 및 페이지 콘텐츠 읽기
graph:neighbors 인접 노드 조회 및 경로 탐색

제한 사항

  • 사용자당 토큰 최대 10개
  • 각 토큰에 최소 하나의 권한 범위가 있어야 해요
  • 각 토큰에 최소 하나의 workspace_id가 있어야 해요 (기본적으로 접근 거부)
  • 만료 기간은 선택 사항이에요 (expires_in_days). 생략하면 만료되지 않아요

토큰 관리

메서드 엔드포인트 설명
GET /api/tokens/ 내 토큰 목록 조회 (원본 값 제외)
POST /api/tokens/ 새 토큰 생성
DELETE /api/tokens/<id>/ 토큰 영구 폐기