[Feature]: Crawl4aiDockerClient has no public option for the API token the 0.9 server requires

Đang mở Phù hợp với người mới
#2,474 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu bằng cách tìm định nghĩa của Crawl4aiDockerClient và theo dõi cách nó gửi yêu cầu, bao gồm cả get_schema(); kiểm tra xem đã có bài kiểm thử cho client hay chưa. Công việc được xem là hoàn tất khi bên gọi có thể cung cấp api_token lúc khởi tạo và token Bearer được gửi trong mọi yêu cầu, với các bài kiểm thử bao quát cả việc crawl và truy cập schema.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

⚙ Done ✨ Enhancement
crawl4ai version

0.9.5 (also on develop; since 0.9.0)

Expected Behavior

The SDK client can talk to a 0.9 server, which requires CRAWL4AI_API_TOKEN on every request.

Current Behavior

Crawl4aiDockerClient has no token option, and every request returns:

401 Authentication required

client.authenticate(email) does not help: it posts only {"email": ...} to /token, but since 0.9.0 /token also requires api_token in the body, so it returns 401 (or 403 when no token is configured).

The only working way is to set a private attribute, as deploy/docker/README.md does today:

client._token = os.environ["CRAWL4AI_API_TOKEN"]
# or
client._http_client.headers["Authorization"] = "Bearer <token>"
Is this reproducible?

Yes

Code snippets
from crawl4ai.docker_client import Crawl4aiDockerClient

async with Crawl4aiDockerClient(base_url="http://localhost:11235") as client:
    await client.crawl(["https://example.com"])
# RequestError: Server error 401: Authentication required
Proposed fix

Add api_token: Optional[str] = None to Crawl4aiDockerClient.__init__ and send it as Authorization: Bearer <token> on every request. With the private _token workaround the header is set only inside crawl(), so get_schema() still returns 401. I'll open a PR.

The broken authenticate() is left for a separate change.

OS

macOS 26.6 (platform-independent)

Python version

3.13

Ngôn ngữ chính
Python
Star
86.8k
Fork
9k
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
26

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của unclecode/crawl4ai

Tất cả issue của unclecode/crawl4ai

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.