123 lines
3.9 KiB
Python
123 lines
3.9 KiB
Python
"""
|
|
Facebook OAuth API Schemas
|
|
|
|
Facebook OAuth 연동 관련 Pydantic 스키마를 정의합니다.
|
|
"""
|
|
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
|
|
class FacebookConnectResponse(BaseModel):
|
|
"""Facebook OAuth 연동 시작 응답
|
|
|
|
Usage:
|
|
GET /sns/facebook/connect
|
|
Facebook OAuth 인증 URL과 CSRF state 토큰을 반환합니다.
|
|
|
|
Example Response:
|
|
{
|
|
"auth_url": "https://www.facebook.com/v21.0/dialog/oauth?client_id=...",
|
|
"state": "abc123xyz"
|
|
}
|
|
"""
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"auth_url": "https://www.facebook.com/v21.0/dialog/oauth?client_id=123&redirect_uri=...",
|
|
"state": "abc123xyz456",
|
|
}
|
|
}
|
|
)
|
|
|
|
auth_url: str = Field(..., description="Facebook 인증 페이지 URL")
|
|
state: str = Field(..., description="CSRF 방지용 state 토큰")
|
|
|
|
|
|
class FacebookTokenResponse(BaseModel):
|
|
"""Facebook 토큰 교환 응답
|
|
|
|
Facebook Graph API에서 반환하는 액세스 토큰 정보입니다.
|
|
"""
|
|
|
|
access_token: str = Field(..., description="액세스 토큰")
|
|
token_type: str = Field(default="bearer", description="토큰 타입")
|
|
expires_in: int = Field(..., description="만료 시간 (초)")
|
|
|
|
|
|
class FacebookUserInfo(BaseModel):
|
|
"""Facebook 사용자 정보
|
|
|
|
Graph API /me 엔드포인트에서 반환하는 사용자 프로필 정보입니다.
|
|
"""
|
|
|
|
id: str = Field(..., description="Facebook 사용자 ID")
|
|
name: str = Field(..., description="사용자 이름")
|
|
email: Optional[str] = Field(default=None, description="이메일 (동의 시 제공)")
|
|
picture: Optional[dict] = Field(default=None, description="프로필 사진 정보")
|
|
|
|
|
|
class FacebookPageInfo(BaseModel):
|
|
"""Facebook 페이지 정보
|
|
|
|
사용자가 관리하는 Facebook 페이지 정보입니다.
|
|
"""
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"id": "123456789",
|
|
"name": "My Business Page",
|
|
"access_token": "EAA...",
|
|
"category": "Business",
|
|
}
|
|
}
|
|
)
|
|
|
|
id: str = Field(..., description="페이지 ID")
|
|
name: str = Field(..., description="페이지 이름")
|
|
access_token: str = Field(..., description="페이지 액세스 토큰")
|
|
category: Optional[str] = Field(default=None, description="페이지 카테고리")
|
|
|
|
|
|
class FacebookAccountResponse(BaseModel):
|
|
"""Facebook 연동 완료 응답
|
|
|
|
Usage:
|
|
Facebook OAuth 콜백 처리 완료 후 반환되는 연동 결과입니다.
|
|
|
|
Example Response:
|
|
{
|
|
"success": true,
|
|
"message": "Facebook 계정 연동이 완료되었습니다.",
|
|
"account_id": 1,
|
|
"platform_user_id": "123456789",
|
|
"platform_username": "홍길동",
|
|
"pages": [...]
|
|
}
|
|
"""
|
|
|
|
model_config = ConfigDict(
|
|
json_schema_extra={
|
|
"example": {
|
|
"success": True,
|
|
"message": "Facebook 계정 연동이 완료되었습니다.",
|
|
"account_id": 1,
|
|
"platform_user_id": "123456789",
|
|
"platform_username": "홍길동",
|
|
"pages": [],
|
|
}
|
|
}
|
|
)
|
|
|
|
success: bool = Field(..., description="연동 성공 여부")
|
|
message: str = Field(..., description="결과 메시지")
|
|
account_id: int = Field(..., description="SocialAccount ID")
|
|
platform_user_id: str = Field(..., description="Facebook 사용자 ID")
|
|
platform_username: str = Field(..., description="Facebook 사용자 이름")
|
|
pages: Optional[list[FacebookPageInfo]] = Field(
|
|
default=None, description="관리 가능한 Facebook 페이지 목록"
|
|
)
|