v2.5.0: CLI-credentials auth, scraper-core dedup, X scraper - #47
Merged
Conversation
v2.4.1: X (Twitter) scraper + limit_per_input
The 7 search classes hand-copied the base's __init__ and context manager; they now inherit a shared core. Amazon/ChatGPT/LinkedIn search gain the standard env-token fallback. No public API or behavior removed.
…gent Token resolution: param → env (BRIGHTDATA_API_TOKEN, BRIGHTDATA_API_KEY) → ~/.../brightdata-cli/credentials.json (read-only) → actionable error. User-agent is now brightdata-sdk-python/<ver> (auth=param|env|cli_credentials).
Prevents a false pass/failure depending on whether the local machine has ~/.config/brightdata-cli/credentials.json (e.g. after 'brightdata login'). The new CLI-credentials fallback means an empty environment no longer guarantees no token is found.
v2.5.0: CLI-credentials auth + scraper-core dedup
# Conflicts: # src/brightdata/client.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Release PR: syncs
mainwithdev, bringing in everything merged intodevsince the last release (v2.4.1 onmain).Included PRs
#46 — v2.5.0: CLI-credentials auth + scraper-core dedup
Python half of the cross-SDK task "SDKs resolve credentials from the CLI store + report auth source in user-agent" (the JS half lives in
sdk-js).Before: the SDK only accepted a token via the
token=parameter or theBRIGHTDATA_API_TOKENenv var — a user who had already runbrightdata loginstill had to copy an API key by hand.Now: with no token given, the SDK falls back to the key the CLI already saved. One login authenticates everything:
Resolution order (first hit wins):
token=parameter →auth=paramBRIGHTDATA_API_TOKEN, thenBRIGHTDATA_API_KEYenv vars →auth=env…/brightdata-cli/credentials.json(read-only) →auth=cli_credentialsbrightdata login, the env var, and the token page)Every request now reports how the token was obtained — making SDK onboarding measurable (feeds the
sdk_auth_sourceMixpanel property):Ticket checklist:
src/brightdata/cli_credentials.py— per-platform path (Linux / macOS / Windows%APPDATA%) +read_cli_credentials()that never raises and never writesBrightDataClientandSyncBrightDataClient(sync delegates to async — pinned by test)brightdata-cli/, never readsconfig.json(pinned by test)Note: engines created by standalone scraper construction (e.g.
AmazonScraper(bearer_token=...)without a client) keep today's behavior and omit the(auth=…)field — the ticket scopes the fallback to the client constructors; extending it there is a small follow-up.Also included: Internal shared
ScraperCore. The 7 search classes each hand-copied the base scraper's__init__+ context manager and had drifted (Amazon/ChatGPT/LinkedIn search lacked the env-token fallback). They now inherit one shared core: −174 lines, drift gone.Tests: 321 passing (57 new). Version → 2.5.0.
Post-merge fix included in this release PR:
test_raises_without_tokenwas updated to mockread_cli_credentials(), since the new CLI fallback meant the test was not hermetic on machines with realbrightdata logincredentials present.#43 — v2.4.1: X (Twitter) scraper + limit_per_input
Adds the X (Twitter) Web Scraper (
client.scrape.x) — previously missing from the SDK.posts,posts_by_profile,posts_by_profiles_array,profiles,profiles_by_username(collect-by-URL and discover), each with async/sync + trigger/status/fetch.limit_per_inputto cap records per input (additive — other scrapers unchanged).