{"record":{"id":"e7e3d7f933c0deb7","repo":"PaddlePaddle/PaddleOCR","slug":"token-is-required-set-paddleocr-access-token-or-p-e7e3d7","errorCode":null,"errorMessage":"Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=.","messagePattern":"Token is required\\. Set PADDLEOCR_ACCESS_TOKEN or pass token=\\.","errorType":"exception","errorClass":"AuthError","httpStatus":null,"severity":"critical","filePath":"paddleocr/_api_client/async_client.py","lineNumber":62,"sourceCode":"\nclass AsyncPaddleOCRClient:\n    \"\"\"Async client for PaddleOCR API.\n\n    Supports asyncio.gather for concurrent job submission and polling.\n    \"\"\"\n\n    def __init__(\n        self,\n        token: Optional[str] = None,\n        base_url: Optional[str] = None,\n        request_timeout: float = 300.0,\n        poll_timeout: float = 600.0,\n        timeout: Optional[float] = None,\n        client_platform: Optional[str] = None,\n    ):\n        self._token = token or os.environ.get(\"PADDLEOCR_ACCESS_TOKEN\", \"\")\n        if not self._token:\n            raise AuthError(\n                \"Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=.\"\n            )\n        resolved_base_url = (\n            base_url or os.environ.get(\"PADDLEOCR_BASE_URL\") or DEFAULT_BASE_URL\n        )\n        if timeout is not None:\n            request_timeout = timeout\n            poll_timeout = timeout\n        self._http = AsyncHTTPClient(\n            self._token,\n            resolved_base_url,\n            request_timeout,\n            client_platform=client_platform,\n        )\n        self._poller = AsyncPoller(self._http, max_wait_time=poll_timeout)\n\n    async def __aenter__(self):\n        await self._http.__aenter__()","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/async_client.py#L44-L80","documentation":"AuthError raised by AsyncPaddleOCRClient.__init__ when neither a token argument nor the PADDLEOCR_ACCESS_TOKEN environment variable is present. The async API client requires an access token before any request can be made, so construction fails fast.","triggerScenarios":"Instantiating the async client with no token= and no PADDLEOCR_ACCESS_TOKEN in the environment (e.g. fresh shell, CI without env secrets, .env file not loaded).","commonSituations":"Deploying to CI/new machines where the env var was never exported; typos in the variable name (PADDLEOCR_ACCESS_TOKEN vs PADDLE_OCR_ACCESS_TOKEN); running examples copied from docs without inserting credentials.","solutions":["Export PADDLEOCR_ACCESS_TOKEN before starting the process","Pass the token explicitly: AsyncPaddleOCRClient(token='...')","Load the token from your secret store (e.g. dotenv, vault) at startup and pass it explicitly rather than relying on the environment"],"exampleFix":"# before\nclient = AsyncPaddleOCRClient()\n# after\nclient = AsyncPaddleOCRClient(token=os.environ['PADDLEOCR_TOKEN'])","handlingStrategy":"validation","validationCode":"import os\n\ntoken = os.environ.get('PADDLEOCR_ACCESS_TOKEN') or load_from_secret_store()\nif not token:\n    raise RuntimeError('missing PaddleOCR access token; configure secret store')","typeGuard":null,"tryCatchPattern":"from paddleocr._api_client.errors import AuthError\n\ntry:\n    client = AsyncPaddleOCRClient(token=token)\nexcept AuthError:\n    # fail the deployment check, do not retry\n    raise","preventionTips":["Pass token= explicitly from your secret manager instead of relying on env vars","Add a startup assertion that the token is present","Name the env var exactly PADDLEOCR_ACCESS_TOKEN"],"tags":["auth","api-client","async","configuration"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}