Skip to content

docs: name BRIGHTDATA_API_KEY in the missing-token error and README - #64

Open
anil-bd wants to merge 1 commit into
mainfrom
docs/brightdata-api-key-env-var
Open

anil-bd wants to merge 1 commit into
mainfrom
docs/brightdata-api-key-env-var

Conversation

@anil-bd

@anil-bd anil-bd commented Sep 30, 2026

Copy link
Copy Markdown

Why

Since 2.5.0 the client reads BRIGHTDATA_API_KEY as a fallback (TOKEN_ENV_VAR_ALT, covered by test_alt_env_var), but the missing-token error and the README only name BRIGHTDATA_API_TOKEN.

BRIGHTDATA_API_KEY is the variable the Bright Data CLI reads and the one docs.brightdata.com now uses in its samples. A user who exported it for the CLI and then hit the SDK error was told to set a different variable.

What changed

  • Error message: the ValidationError for a missing token lists BRIGHTDATA_API_KEY (noting the CLI reads it too), then BRIGHTDATA_API_TOKEN.
  • README: the configuration example exports BRIGHTDATA_API_KEY, and notes that BRIGHTDATA_API_TOKEN also works and wins when both are set.
  • Test: test_no_credentials_error_is_actionable also asserts BRIGHTDATA_API_KEY is in the message.

Lookup order is unchanged: token argument, BRIGHTDATA_API_TOKEN, BRIGHTDATA_API_KEY, then the CLI's stored credentials.

New error text:

API token required but not found.

Provide token in one of these ways:
  1. Pass as parameter: BrightDataClient(token='your_token')
  2. Set environment variable: BRIGHTDATA_API_KEY (also read by the Bright Data CLI)
     or BRIGHTDATA_API_TOKEN
  3. Log in with the Bright Data CLI: brightdata login

Get your API token from: https://brightdata.com/cp/setting/users

Testing

  • pytest tests/unit: 335 passed
  • ruff check src tests: all checks passed
  • black --check src tests: no changes

The client has read BRIGHTDATA_API_KEY as a fallback since 2.5.0
(TOKEN_ENV_VAR_ALT), but the missing-token error and the README only named
BRIGHTDATA_API_TOKEN. BRIGHTDATA_API_KEY is the variable the Bright Data CLI
reads and the one the docs use, so a user who set it for the CLI was told to
set a different variable.

- ValidationError lists BRIGHTDATA_API_KEY first, then BRIGHTDATA_API_TOKEN
- README configuration example exports BRIGHTDATA_API_KEY and notes that
  BRIGHTDATA_API_TOKEN also works and wins when both are set
- test_no_credentials_error_is_actionable also asserts BRIGHTDATA_API_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant