OpenBB-finance/OpenBB · error · UnauthorizedError
Missing credentials: congress_gov_api_key
Error message
Missing credentials: congress_gov_api_key
What it means
check_api_key reads congress_gov_api_key from the active OpenBB UserSettings credentials and raises UnauthorizedError when it is empty or unset. Every congress_gov helper calls this before building a request URL, so it is the gatekeeper error for the entire provider. The key is free but must be obtained from api.congress.gov and stored in OpenBB's user settings.
Solutions
- Get a free key at https://api.congress.gov/sign-up/ and store it: openbb.credentials.congress_gov_api_key = '...'
- Verify with `openbb.credentials` (or obb.account.get) that the key is present in the active profile
- In CI, inject the key via environment/secret and configure it in the job's bootstrap step
Example fix
# before bills = obb.congress.bills(provider='congress_gov') # raises UnauthorizedError # after obb.credentials.congress_gov_api_key = os.environ['CONGRESS_GOV_API_KEY'] bills = obb.congress.bills(provider='congress_gov')
Defensive patterns
Strategy: validation
Validate before calling
import os
def has_congress_key() -> bool:
return bool(os.getenv('CONGRESS_GOV_API_KEY')) # if provisioning via env
# Configure once at startup:
# obb.credentials.congress_gov_api_key = os.environ['CONGRESS_GOV_API_KEY'] Try / catch
from openbb_core.provider.standard_models.errors import UnauthorizedError # path per version
try:
data = await helper_call()
except UnauthorizedError:
raise SystemExit('Configure congress_gov_api_key first: obb.credentials.congress_gov_api_key = KEY') Prevention
- Set the credential in a startup bootstrap step, not per call
- Add a preflight check listing required credentials before long batch runs
- Persist credentials via OpenBB's hub/local profile so restarts keep them
When it happens
Trigger: Any congress_gov endpoint call (bills, laws, amendments, committee documents) before the key has been configured; a fresh OpenBB installation; a runtime where a different profile/hub account is active and lacks the credential.
Common situations: New users who never ran the credential setup; CI containers without persisted settings; key stored under the wrong credential name; switching OpenBB accounts loses locally stored credentials.
Related errors
- ->
- ->
- Invalid username or password.
- Missing credential ' '. Refer to the documentation for…
- Provider fallback failed. [Providers]
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/03e924dd958e20fc.
Report an issue: GitHub.
Appendix: source
Thrown at openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py:55
return congress_number
def check_api_key() -> str:
"""Check if the Congress.gov API key is set in user settings.
Raises UnauthorizedError if the API key is not set.
"""
# pylint: disable=import-outside-toplevel
from openbb_core.app.service.user_service import UserSettings
from pydantic import SecretStr
credentials = UserSettings().credentials
api_key = getattr(
credentials, "congress_gov_api_key", SecretStr("")
).get_secret_value()
if not api_key:
raise UnauthorizedError("Missing credentials: congress_gov_api_key")
return api_key
def download_bills(urls: list[str]) -> list:
"""Download a bill's text in PDF format.
This helper is not intended to be used directly.
OpenBB Workspace uses this, as a POST endpoint, to download
the selected bill(s) in PDF format. Results are returned as base64-encoded PDF content.
Parameters
----------
urls: list[str]
A list of URLs to download. Each URL must be a valid Congress.gov URL.
ReturnsView on GitHub (pinned to 3e071fcc2c)