PaddlePaddle/PaddleOCR · critical · AuthError
Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=
Error message
Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=.
What it means
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.
Source
Thrown at paddleocr/_api_client/async_client.py:62
class AsyncPaddleOCRClient:
"""Async client for PaddleOCR API.
Supports asyncio.gather for concurrent job submission and polling.
"""
def __init__(
self,
token: Optional[str] = None,
base_url: Optional[str] = None,
request_timeout: float = 300.0,
poll_timeout: float = 600.0,
timeout: Optional[float] = None,
client_platform: Optional[str] = None,
):
self._token = token or os.environ.get("PADDLEOCR_ACCESS_TOKEN", "")
if not self._token:
raise AuthError(
"Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=."
)
resolved_base_url = (
base_url or os.environ.get("PADDLEOCR_BASE_URL") or DEFAULT_BASE_URL
)
if timeout is not None:
request_timeout = timeout
poll_timeout = timeout
self._http = AsyncHTTPClient(
self._token,
resolved_base_url,
request_timeout,
client_platform=client_platform,
)
self._poller = AsyncPoller(self._http, max_wait_time=poll_timeout)
async def __aenter__(self):
await self._http.__aenter__()View on GitHub (pinned to 2661c7c0ef)
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
Example fix
# before client = AsyncPaddleOCRClient() # after client = AsyncPaddleOCRClient(token=os.environ['PADDLEOCR_TOKEN'])
Defensive patterns
Strategy: validation
Validate before calling
import os
token = os.environ.get('PADDLEOCR_ACCESS_TOKEN') or load_from_secret_store()
if not token:
raise RuntimeError('missing PaddleOCR access token; configure secret store') Try / catch
from paddleocr._api_client.errors import AuthError
try:
client = AsyncPaddleOCRClient(token=token)
except AuthError:
# fail the deployment check, do not retry
raise Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Token is required. Set PADDLEOCR_ACCESS_TOKEN or pass token=
- PaddleOCR source adapter is not configured.
- worker mode does not support a custom fetch implementation.
- Conflicting values provided for ${label}: ${aliases.join(",
- ${warnings.join(" ")} (pipeline warnings promoted to errors
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/e7e3d7f933c0deb7.
Report an issue: GitHub.