Update app.py
Browse files25 unmodified lines2627282930311 unmodified line333435363738394041424344454647484950515253545556575859606125 unmodified linesdef 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,1 unmodified line)authed_session = google.auth.transport.requests.AuthorizedSession(credentials)project_id = service_account_info["project_id"]app_ids = os.environ.get("FIREBASE_APP_IDS", "").split(",")for app_id in app_ids:app_id = app_id.strip()if not app_id:continueprint(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 Trueprint("[AppCheck] ❌ Token invalid for all App IDs")return Falseexcept Exception as e:print(f"[AppCheck] 🔥 Exception while validating App Check token: {e}")return Falsedef download_video_audio_and_metadata(url: str) -> tuple[str, str, str]:25 unmodified lines262728293031321 unmodified line343536373839404142434445464748495025 unmodified linesdef 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,1 unmodified line)authed_session = google.auth.transport.requests.AuthorizedSession(credentials)url = "https://firebaseappcheck.googleapis.com/v1beta/projects/{project_id}:verifyAppCheckToken".format(project_id=service_account_info["project_id"])response = authed_session.post(url, json={"appCheckToken": app_check_token})print(f"[AppCheck] Status: {response.status_code}")print(f"[AppCheck] Body: {response.text}")return response.status_code == 200except Exception as e:print(f"[AppCheck] 🔥 Exception while validating token: {e}")return Falsedef download_video_audio_and_metadata(url: str) -> tuple[str, str, str]:
app.py+9-20