- youtube_uploader.py: YOUTUBE_REFRESH_TOKEN/CLIENT_ID/CLIENT_SECRET 환경변수 폴백 추가 (token.json 없는 Docker 환경에서 브랜드 계정 인증 가능) - shorts_config.json: corners_eligible를 실제 블로그 코너명으로 수정 - caption_renderer.py: render_captions() 반환값 누락 수정 - get_token.py: web→installed 타입 변환, port 8080 고정, prompt=consent 추가 - get_youtube_token.py: YouTube 전용 OAuth 토큰 발급 스크립트 (별도 클라이언트) - CLAUDE.md: 프로젝트 개요, 배포 방법, 핵심 파일, YouTube 채널 정보 추가 - publisher_bot.py: 이미지 분산 배치, SEO 검증, 버그 수정 - scheduler.py: 알림 강화, atomic write, 중복 방지, hot reload 개선 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""
|
|
YouTube 전용 OAuth2 토큰 발급 스크립트
|
|
credentials_youtube.json 사용 (Blogger와 별도 OAuth 클라이언트)
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
from google_auth_oauthlib.flow import InstalledAppFlow
|
|
from google.oauth2.credentials import Credentials
|
|
from google.auth.transport.requests import Request
|
|
|
|
SCOPES = [
|
|
'https://www.googleapis.com/auth/youtube.upload',
|
|
'https://www.googleapis.com/auth/youtube',
|
|
]
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
CREDENTIALS_PATH = os.path.join(BASE_DIR, 'credentials_youtube.json')
|
|
|
|
|
|
def main():
|
|
if not os.path.exists(CREDENTIALS_PATH):
|
|
print(f"[ERROR] credentials_youtube.json 없음: {CREDENTIALS_PATH}")
|
|
sys.exit(1)
|
|
|
|
with open(CREDENTIALS_PATH) as f:
|
|
client_config = json.load(f)
|
|
if 'web' in client_config and 'installed' not in client_config:
|
|
client_config['installed'] = client_config.pop('web')
|
|
|
|
flow = InstalledAppFlow.from_client_config(client_config, SCOPES)
|
|
creds = flow.run_local_server(port=8080, prompt='consent')
|
|
print("[OK] 새 토큰 발급 완료")
|
|
|
|
token_data = json.loads(creds.to_json())
|
|
refresh_token = token_data.get('refresh_token', '')
|
|
|
|
print("\n" + "=" * 50)
|
|
print("YouTube 토큰 발급 성공!")
|
|
print("=" * 50)
|
|
print(f"\nYOUTUBE_REFRESH_TOKEN:\n{refresh_token}")
|
|
print(f"\n이 값을 .env 파일의 YOUTUBE_REFRESH_TOKEN 에 붙여넣으세요.")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|