{"record":{"id":"03e924dd958e20fc","repo":"OpenBB-finance/OpenBB","slug":"missing-credentials-congress-gov-api-key","errorCode":null,"errorMessage":"Missing credentials: congress_gov_api_key","messagePattern":"Missing credentials: congress_gov_api_key","errorType":"exception","errorClass":"UnauthorizedError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py","lineNumber":55,"sourceCode":"    return congress_number\n\n\ndef check_api_key() -> str:\n    \"\"\"Check if the Congress.gov API key is set in user settings.\n\n    Raises UnauthorizedError if the API key is not set.\n    \"\"\"\n    # pylint: disable=import-outside-toplevel\n    from openbb_core.app.service.user_service import UserSettings\n    from pydantic import SecretStr\n\n    credentials = UserSettings().credentials\n    api_key = getattr(\n        credentials, \"congress_gov_api_key\", SecretStr(\"\")\n    ).get_secret_value()\n\n    if not api_key:\n        raise UnauthorizedError(\"Missing credentials: congress_gov_api_key\")\n\n    return api_key\n\n\ndef download_bills(urls: list[str]) -> list:\n    \"\"\"Download a bill's text in PDF format.\n\n    This helper is not intended to be used directly.\n\n    OpenBB Workspace uses this, as a POST endpoint, to download\n    the selected bill(s) in PDF format. Results are returned as base64-encoded PDF content.\n\n    Parameters\n    ----------\n    urls: list[str]\n        A list of URLs to download. Each URL must be a valid Congress.gov URL.\n\n    Returns","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/congress_gov/openbb_congress_gov/utils/helpers.py#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nbills = obb.congress.bills(provider='congress_gov')  # raises UnauthorizedError\n\n# after\nobb.credentials.congress_gov_api_key = os.environ['CONGRESS_GOV_API_KEY']\nbills = obb.congress.bills(provider='congress_gov')","handlingStrategy":"validation","validationCode":"import os\n\ndef has_congress_key() -> bool:\n    return bool(os.getenv('CONGRESS_GOV_API_KEY'))  # if provisioning via env\n\n# Configure once at startup:\n# obb.credentials.congress_gov_api_key = os.environ['CONGRESS_GOV_API_KEY']","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.standard_models.errors import UnauthorizedError  # path per version\ntry:\n    data = await helper_call()\nexcept UnauthorizedError:\n    raise SystemExit('Configure congress_gov_api_key first: obb.credentials.congress_gov_api_key = KEY')","preventionTips":["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"],"tags":["congress-gov","authentication","credentials","configuration"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}