OpenBB-finance/OpenBB · error · UnauthorizedError

Unauthorized Benzinga request -> {results[0]}

Error message

Unauthorized Benzinga request -> {results[0]}

What it means

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.

Source

Thrown at openbb_platform/providers/benzinga/openbb_benzinga/utils/helpers.py:18

"""Benzinga Helpers."""

from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.utils.errors import UnauthorizedError


async def response_callback(response, _):
    """Response callback."""
    # pylint: disable=import-outside-toplevel
    results = await response.json()
    if (
        results
        and isinstance(results, list)
        and len(results) == 1
        and isinstance(results[0], str)
    ):
        if "access denied" in results[0].lower():
            raise UnauthorizedError(f"Unauthorized Benzinga request -> {results[0]}")
        raise OpenBBError(results[0])

    return results

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Set a valid key: obb.user.credentials.benzinga_api_key = 'your_key' (or via the /account credentials UI)
  2. Confirm the key is active and has remaining quota on the Benzinga developer dashboard
  3. Verify the key is entitled to the specific endpoint being called (some are tier-gated)
  4. Retry after quota resets if a rate limit was hit

Example fix

// before
obb.news(provider='benzinga')  # UnauthorizedError: access denied

// after
obb.user.credentials.benzinga_api_key = 'VALID_KEY'
obb.news(provider='benzinga')
Defensive patterns

Strategy: validation

Validate before calling

async def check_benzinga_key(api_key: str) -> bool:
    import requests
    r = requests.get('https://api.benzinga.com/api/v2/news',
                     params={'token': api_key, 'limit': 1})
    body = r.json()
    return not (isinstance(body, list) and body and 'access denied' in str(body[0]).lower())

Try / catch

from openbb_core.provider.utils.errors import UnauthorizedError
try:
    news = obb.news(provider='benzinga')
except UnauthorizedError as e:
    raise SystemExit('Fix benzinga_api_key: ' + str(e)) from e

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/b0420c7a02bc6e73. Report an issue: GitHub.