유튜브 인증 로직 수정

This commit is contained in:
skkim committed 2026-05-13 15:54:24 +09:00
1 parent ec3e0159e8
commit f47dd423c5
4 files changed
+26 -10

No files matched your search

+2 -1
View File
@@ -24,12 +24,13 @@ class BaseOAuthClient(ABC):
platform: SocialPlatform
@abstractmethod
def get_authorization_url(self, state: str) -> str:
def get_authorization_url(self, state: str, force_consent: bool = False) -> str:
"""
OAuth 인증 URL 생성
Args:
state: CSRF 방지용 state 토큰
force_consent: True면 동의 화면 강제 표시 (refresh_token 재발급 필요 시)
Returns:
str: OAuth 인증 페이지 URL
+5 -4
View File
@@ -43,12 +43,13 @@ class YouTubeOAuthClient(BaseOAuthClient):
self.client_secret = social_oauth_settings.YOUTUBE_CLIENT_SECRET
self.redirect_uri = social_oauth_settings.YOUTUBE_REDIRECT_URI
def get_authorization_url(self, state: str) -> str:
def get_authorization_url(self, state: str, force_consent: bool = False) -> str:
"""
Google OAuth 인증 URL 생성
Args:
state: CSRF 방지용 state 토큰
force_consent: True면 동의 화면 강제 표시하여 refresh_token 재발급
Returns:
str: Google OAuth 인증 페이지 URL
@@ -58,12 +59,12 @@ class YouTubeOAuthClient(BaseOAuthClient):
"redirect_uri": self.redirect_uri,
"response_type": "code",
"scope": " ".join(YOUTUBE_SCOPES),
"access_type": "offline", # refresh_token 받기 위해 필요
"prompt": "select_account", # 계정 선택만 표시 (동의 화면은 최초 1회만)
"access_type": "offline",
"prompt": "consent" if force_consent else "select_account",
"state": state,
}
url = f"{self.AUTHORIZATION_URL}?{urlencode(params)}"
logger.debug(f"[YOUTUBE_OAUTH] 인증 URL 생성: {url[:100]}...")
logger.debug(f"[YOUTUBE_OAUTH] 인증 URL 생성 - force_consent: {force_consent}, url: {url[:100]}...")
return url
async def exchange_code(self, code: str) -> OAuthTokenResponse: