crawl4ai icon indicating copy to clipboard operation
crawl4ai copied to clipboard

[Bug]: Authentication required. Call authenticate() first in Docker

Open QuangTQV opened this issue 8 months ago • 2 comments

crawl4ai version

0.6.1

Expected Behavior

When setting security.enabled: false and jwt_enabled: false in the config.yml, I expect the Crawl4AI server to allow API access without requiring authentication (i.e., calling authenticate() should not be needed).

I should be able to directly use Crawl4aiDockerClient or send requests to /crawl without providing a JWT token.

Current Behavior

Despite setting security.enabled: false and jwt_enabled: false in the server configuration, when trying to crawl via the SDK, I get this error:

crawl4ai.docker_client.Crawl4aiClientError: Authentication required. Call authenticate() first.

This happens immediately when calling client.crawl(...), even though authentication should be disabled according to the config.

It seems the client always expects authentication to be active, without checking if security is actually turned off.

Is this reproducible?

Yes

Inputs Causing the Bug


Steps to Reproduce


Code snippets


OS

Macos

Python version

3.10

Browser

No response

Browser version

No response

Error logs & Screenshots (if applicable)

No response

QuangTQV avatar Apr 29 '25 08:04 QuangTQV

It's 100% expecting self._token before it does ANYTHING -- "docker_client.py" line 98

`

async def crawl(
    self,
    urls: List[str],
    browser_config: Optional[BrowserConfig] = None,
    crawler_config: Optional[CrawlerRunConfig] = None
) -> Union[CrawlResult, List[CrawlResult], AsyncGenerator[CrawlResult, None]]:
    """Execute a crawl operation."""
    if not self._token:
        raise Crawl4aiClientError("Authentication required. Call authenticate() first.")
    await self._check_server()

`

lweighall avatar May 01 '25 18:05 lweighall

Confirmed manually setting the token allows it to work:

client._token = "test"

lweighall avatar May 01 '25 18:05 lweighall

Hello @QuangTQV this issue has been resolved in the latest Docker build. Try it out and let us know.

Ahmed-Tawfik94 avatar Aug 12 '25 09:08 Ahmed-Tawfik94