SDK: brightdata-sdk 2.5.2 (latest on PyPI), Python 3.12, macOS. Account without a payment method (a new free account).
Steps to reproduce
pip install brightdata-sdk==2.5.2
export BRIGHTDATA_API_TOKEN=YOUR_API_KEY # a token from an account with no payment method
python - <<'PY'
from brightdata import SyncBrightDataClient
with SyncBrightDataClient() as client: # every argument at its default
print(client.search.instagram.profiles("nasa").data[0]["followers"])
PY
Actual
The client never gets to the scraper call. Entering the context manager fails:
Failed to create zone 'sdk_unlocker' due to insufficient permissions
❌ ZONE CREATION BLOCKED: API token lacks required permissions
Error: Forbidden (403): {"msg":"A payment method is required for this zone action. Please add a payment method and try again.","err_id":"payment_method_required"}
Fix: Update your token permissions at https://brightdata.com/cp/setting/users
AuthenticationError: Forbidden (403): {"msg":"A payment method is required for this zone action. Please add a payment method and try again.","err_id":"payment_method_required"}
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x10516cc50>
Expected
A scraper call needs no zone. The client should not try to create sdk_unlocker and sdk_serp unless Web Unlocker or SERP is actually used. The _ensure_zones docstring already describes that behaviour: "This is called automatically before the first API request." In practice it is called unconditionally from __aenter__ (brightdata/client.py, await self._ensure_zones() right after the optional token validation), so every free account fails on the first with block, before any request.
Three smaller things in the same path:
- The printed advice, "API token lacks required permissions ... Update your token permissions", is wrong for this error. The API says a payment method is missing, not a permission.
- When
__aenter__ raises, engine.__aexit__ is not called, hence the "Unclosed client session" warning.
auto_create_zones defaults to True. Defaulting to False, or creating lazily on first Web Unlocker / SERP use, would remove the failure for everyone who only uses scrapers.
Workaround
SyncBrightDataClient(auto_create_zones=False). Every example in https://github.com/brightdata/instagram-scraper-python passes it for this reason.
SDK: brightdata-sdk 2.5.2 (latest on PyPI), Python 3.12, macOS. Account without a payment method (a new free account).
Steps to reproduce
Actual
The client never gets to the scraper call. Entering the context manager fails:
Expected
A scraper call needs no zone. The client should not try to create
sdk_unlockerandsdk_serpunless Web Unlocker or SERP is actually used. The_ensure_zonesdocstring already describes that behaviour: "This is called automatically before the first API request." In practice it is called unconditionally from__aenter__(brightdata/client.py,await self._ensure_zones()right after the optional token validation), so every free account fails on the firstwithblock, before any request.Three smaller things in the same path:
__aenter__raises,engine.__aexit__is not called, hence the "Unclosed client session" warning.auto_create_zonesdefaults toTrue. Defaulting toFalse, or creating lazily on first Web Unlocker / SERP use, would remove the failure for everyone who only uses scrapers.Workaround
SyncBrightDataClient(auto_create_zones=False). Every example in https://github.com/brightdata/instagram-scraper-python passes it for this reason.