Update app.py
Browse files24 unmodified lines252627282930319 unmodified lines41424344454647484950515247535455495657515859606164 unmodified lines12612712812913013113213313413513613713813914024 unmodified lines
def validate_app_check_token(app_check_token: str) -> bool: try: print("[AppCheck] Validating App Check token...") service_account_info = json.loads(os.environ["FIREBASE_SERVICE_ACCOUNT_JSON"]) credentials = service_account.Credentials.from_service_account_info( service_account_info,9 unmodified lines if not app_id: continue
print(f"[AppCheck] Trying App ID: {app_id}") url = f"https://firebaseappcheck.googleapis.com/v1/projects/{project_id}/apps/{app_id}:verifyAppCheckToken" response = authed_session.post(url, json={"appCheckToken": app_check_token})
print(f"[AppCheck] Status code for {app_id}: {response.status_code}") print(f"[AppCheck] Response body: {response.text}")
if response.status_code == 200: print(f"[AppCheck] ✅ Token valid for App ID: {app_id}") return True return True
print("[AppCheck] ❌ Token invalid for all App IDs") return False return False except Exception as e: print(f"App Check validation error: {e}") print(f"[AppCheck] 🔥 Exception while validating App Check token: {e}") return False
def download_video_audio_and_metadata(url: str) -> tuple[str, str, str]:64 unmodified lines x_firebase_appcheck: str = Header(None)): if not x_firebase_appcheck: print("[/analyze] ❌ Missing App Check token") return JSONResponse(status_code=403, content={"error": "Missing Firebase App Check token"})
print("[/analyze] App Check token received") if not validate_app_check_token(x_firebase_appcheck): print("[/analyze] ❌ Invalid App Check token") return JSONResponse(status_code=403, content={"error": "Invalid App Check token"})
print("[/analyze] ✅ App Check token validated") audio_url = request.audio_url gemini_api_key = request.gemini_api_keyapp.py+16-3