시작하기

인증

IVGraph는 두 가지 인증 방식을 사용해요. 웹 사용자용 JWT 토큰(노션 OAuth를 통해 발급)과 LLM 에이전트 및 자동화용 서비스 토큰(Pro 및 Max 요금제에서 사용)이에요.

노션 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 /auth/notion/callback?code=...
        |  -> Backend exchanges code for Notion token
        |  -> Creates/updates Django user
        |  -> Issues JWT tokens (httpOnly cookies, never in the URL)
        v
Redirect back to the page where sign-in started (?next=), or to /dashboard/

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 /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 파이프라인을 위해 설계되었어요.

서비스 토큰은 US$1.99 Pro 주간 이용권을 포함한 Pro 및 Max 요금제에서 사용할 수 있어요. Free와 Plus에서는 토큰을 사용한 요청과 토큰 생성 요청에 api_plan_required 코드와 함께 403이 반환돼요. V1 LLM API의 요금제 섹션을 참고하세요.

토큰 형식

  • 접두사: 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"
}

Free와 Plus에서는 이 요청에 api_plan_required 코드와 함께 403이 반환되며, 토큰은 생성되지 않아요.

권한 범위

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

제한 사항

  • US$1.99 Pro 주간 이용권을 포함한 Pro 및 Max 요금제에서만 사용 가능. Free와 Plus에서는 기존 토큰이 유지되지만 일시 중지되며, 계정이 Pro 또는 Max 요금제로 전환되는 즉시 다시 사용 가능
  • 사용자당 최대 10개 토큰
  • 각 토큰에 최소 하나의 권한 범위 필요
  • 각 토큰에 최소 하나의 workspace_id 필요(기본적으로 접근 거부)
  • 만료 기간은 선택 사항(expires_in_days) — 생략하면 만료되지 않음

토큰 관리

메서드 엔드포인트 설명
GET /api/tokens/ 내 토큰 목록(원본 값 제외)과 현재 요금제에서 토큰을 사용할 수 있는지 나타내는 api_access 조회
POST /api/tokens/ 새 토큰 생성(Pro 및 Max 요금제)
DELETE /api/tokens/<id>/ 토큰 폐기(영구적, 모든 요금제에서 가능)

Pro와 Max에서 api_access는 {"allowed": true}예요. 그 외에는 {"allowed": false, "reason": "plan", "upgrade_url": "https://ivgraph.com/billing/", ...}예요. 요금제에 API가 포함되어 있지만 마지막 결제에 실패한 경우에는 reason이 payment예요.