Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,12 @@ async def _solve_recaptcha_with_api_service(
create_url = f"{base_url.rstrip('/')}/createTask"
get_url = f"{base_url.rstrip('/')}/getTaskResult"

# Do not use curl_cffi impersonation for captcha API JSON endpoints: some ASGI servers
# (for example FastAPI/Uvicorn) may receive an empty body and return 422.
async with AsyncSession() as session:
create_resp = await session.post(
create_url,
json={"clientKey": client_key, "task": task},
impersonate="chrome120",
timeout=30
)
create_json = create_resp.json()
Expand All @@ -387,7 +388,6 @@ async def _solve_recaptcha_with_api_service(
poll_resp = await session.post(
get_url,
json={"clientKey": client_key, "taskId": task_id},
impersonate="chrome120",
timeout=30
)
poll_json = poll_resp.json()
Expand Down
6 changes: 4 additions & 2 deletions src/services/flow_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,8 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str
page_action = action

try:
# Do not use curl_cffi impersonation for captcha API JSON endpoints: some ASGI
# servers (for example FastAPI/Uvicorn) may receive an empty body and return 422.
async with AsyncSession() as session:
create_url = f"{base_url}/createTask"
create_data = {
Expand All @@ -2409,7 +2411,7 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str
}
}

result = await session.post(create_url, json=create_data, impersonate="chrome110")
result = await session.post(create_url, json=create_data)
result_json = result.json()
task_id = result_json.get('taskId')

Expand All @@ -2426,7 +2428,7 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str
"clientKey": client_key,
"taskId": task_id
}
result = await session.post(get_url, json=get_data, impersonate="chrome110")
result = await session.post(get_url, json=get_data)
result_json = result.json()

debug_logger.log_info(f"[reCAPTCHA {method}] polling #{i+1}: {result_json}")
Expand Down