### Added - 🔍 **OAuth Detailed Logging**: Добавлено пошаговое логирование OAuth callback для диагностики ошибок `auth_failed` - 🧪 **OAuth Diagnostic Tools**: Создан `oauth_debug.py` для анализа OAuth callback параметров и диагностики проблем - 📊 **OAuth Test Helper**: Добавлен `oauth_test_helper.py` для создания тестовых состояний OAuth в Redis - 🔧 **OAuth Provider Detection**: Автоматическое определение OAuth провайдера по формату authorization code ### Fixed - 🚨 **OAuth Callback Error Handling**: Улучшена обработка исключений в OAuth callback с детальным логированием каждого шага - 🔍 **OAuth Exception Tracking**: Добавлено логирование исключений на каждом этапе: token exchange, profile fetch, user creation, session creation - 📋 **OAuth Error Diagnosis**: Реализована система диагностики для выявления точной причины `error=auth_failed` редиректов ### Changed - 🔧 **OAuth Callback Flow**: Разделен OAuth callback на логические шаги с индивидуальным error handling - 📝 **OAuth Error Messages**: Улучшены сообщения об ошибках для более точной диагностики проблем
This commit is contained in:
@@ -641,12 +641,15 @@ async def oauth_callback_http(request: Request) -> JSONResponse | RedirectRespon
|
||||
if not oauth_data:
|
||||
logger.warning(f"🚨 OAuth state {state} not found or expired")
|
||||
# Более информативная ошибка для пользователя
|
||||
return JSONResponse({
|
||||
"error": "oauth_state_expired",
|
||||
"message": "OAuth session expired. Please try logging in again.",
|
||||
"details": "The OAuth state was not found in Redis (expired or already used)",
|
||||
"action": "restart_oauth_flow"
|
||||
}, status_code=400)
|
||||
return JSONResponse(
|
||||
{
|
||||
"error": "oauth_state_expired",
|
||||
"message": "OAuth session expired. Please try logging in again.",
|
||||
"details": "The OAuth state was not found in Redis (expired or already used)",
|
||||
"action": "restart_oauth_flow",
|
||||
},
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
provider = oauth_data.get("provider")
|
||||
if not provider:
|
||||
@@ -713,7 +716,9 @@ async def oauth_callback_http(request: Request) -> JSONResponse | RedirectRespon
|
||||
logger.error(f"❌ Failed to get user profile for {provider} - empty profile returned")
|
||||
return JSONResponse({"error": "Failed to get user profile"}, status_code=400)
|
||||
|
||||
logger.info(f"✅ Got user profile for {provider}: id={profile.get('id')}, email={profile.get('email')}, name={profile.get('name')}")
|
||||
logger.info(
|
||||
f"✅ Got user profile for {provider}: id={profile.get('id')}, email={profile.get('email')}, name={profile.get('name')}"
|
||||
)
|
||||
|
||||
# 🔄 Step 3: Creating or updating user
|
||||
logger.info(f"🔄 Step 3: Creating or updating user for {provider}...")
|
||||
|
||||
Reference in New Issue
Block a user