{"record":{"id":"b0420c7a02bc6e73","repo":"OpenBB-finance/OpenBB","slug":"unauthorized-benzinga-request-results-0","errorCode":null,"errorMessage":"Unauthorized Benzinga request -> {results[0]}","messagePattern":"Unauthorized Benzinga request -> (.+?)","errorType":"exception","errorClass":"UnauthorizedError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/benzinga/openbb_benzinga/utils/helpers.py","lineNumber":18,"sourceCode":"\"\"\"Benzinga Helpers.\"\"\"\n\nfrom openbb_core.app.model.abstract.error import OpenBBError\nfrom openbb_core.provider.utils.errors import UnauthorizedError\n\n\nasync def response_callback(response, _):\n    \"\"\"Response callback.\"\"\"\n    # pylint: disable=import-outside-toplevel\n    results = await response.json()\n    if (\n        results\n        and isinstance(results, list)\n        and len(results) == 1\n        and isinstance(results[0], str)\n    ):\n        if \"access denied\" in results[0].lower():\n            raise UnauthorizedError(f\"Unauthorized Benzinga request -> {results[0]}\")\n        raise OpenBBError(results[0])\n\n    return results\n","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/benzinga/openbb_benzinga/utils/helpers.py#L1-L22","documentation":"Raised by Benzinga's shared response_callback when the API returns a single-element list of strings containing 'access denied'. The callback inspects every Benzinga response, and this specific shape is how Benzinga reports credential failures. It is an UnauthorizedError, so the root cause is the API key, not the query.","triggerScenarios":"Any Benzinga provider call (news, ratings, price targets, etc.) where the api_key is missing, expired, out of credits, or not entitled to the requested endpoint; the response body is e.g. [\"Access denied for user\"] which the callback converts into this error.","commonSituations":"Key not set in OpenBB credentials (obb.user.credentials.benzinga_api_key), a trial key that lapsed, exceeding the request quota, or requesting a premium endpoint on a basic plan.","solutions":["Set a valid key: obb.user.credentials.benzinga_api_key = 'your_key' (or via the /account credentials UI)","Confirm the key is active and has remaining quota on the Benzinga developer dashboard","Verify the key is entitled to the specific endpoint being called (some are tier-gated)","Retry after quota resets if a rate limit was hit"],"exampleFix":"// before\nobb.news(provider='benzinga')  # UnauthorizedError: access denied\n\n// after\nobb.user.credentials.benzinga_api_key = 'VALID_KEY'\nobb.news(provider='benzinga')","handlingStrategy":"validation","validationCode":"async def check_benzinga_key(api_key: str) -> bool:\n    import requests\n    r = requests.get('https://api.benzinga.com/api/v2/news',\n                     params={'token': api_key, 'limit': 1})\n    body = r.json()\n    return not (isinstance(body, list) and body and 'access denied' in str(body[0]).lower())","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import UnauthorizedError\ntry:\n    news = obb.news(provider='benzinga')\nexcept UnauthorizedError as e:\n    raise SystemExit('Fix benzinga_api_key: ' + str(e)) from e","preventionTips":["Validate the Benzinga token with a one-off request at startup","Store the key via obb.user.credentials, never hardcoded","Track quota on the Benzinga dashboard for scheduled jobs"],"tags":["benzinga","auth","api-key","unauthorized","provider"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}