Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Deploy: Consolidated gold tables, fixed nginx docs routing
Browse files- api/routes/auth.py +17 -1
api/routes/auth.py
CHANGED
|
@@ -412,9 +412,25 @@ async def get_user_info(provider: str, access_token: str, config: dict) -> dict:
|
|
| 412 |
}
|
| 413 |
|
| 414 |
elif provider == 'facebook':
|
| 415 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
data = resp.json()
|
| 417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
# Facebook may not return email if permission not approved in App Review
|
| 419 |
# Generate a placeholder email using Facebook ID if email not available
|
| 420 |
email = data.get('email')
|
|
|
|
| 412 |
}
|
| 413 |
|
| 414 |
elif provider == 'facebook':
|
| 415 |
+
# Facebook uses access token as query parameter, not Bearer header
|
| 416 |
+
userinfo_url_with_token = f"{config['userinfo_url']}&access_token={access_token}"
|
| 417 |
+
resp = await client.get(userinfo_url_with_token)
|
| 418 |
+
|
| 419 |
+
# Log response for debugging
|
| 420 |
+
logger.info(f"Facebook API response status: {resp.status_code}")
|
| 421 |
+
logger.info(f"Facebook API response: {resp.text[:500]}")
|
| 422 |
+
|
| 423 |
+
if resp.status_code != 200:
|
| 424 |
+
logger.error(f"Facebook userinfo request failed: {resp.status_code} - {resp.text}")
|
| 425 |
+
return None
|
| 426 |
+
|
| 427 |
data = resp.json()
|
| 428 |
|
| 429 |
+
# Validate we got required data
|
| 430 |
+
if not data.get('id'):
|
| 431 |
+
logger.error(f"Facebook did not return user ID. Response: {data}")
|
| 432 |
+
return None
|
| 433 |
+
|
| 434 |
# Facebook may not return email if permission not approved in App Review
|
| 435 |
# Generate a placeholder email using Facebook ID if email not available
|
| 436 |
email = data.get('email')
|