OpenBB-finance/OpenBB · error · UnauthorizedError

[Error] -> {e}

Error message

[Error] -> {e}

What it means

Raised when the wrapped command raised an UnauthorizedError (typically an HTTP 401/403 from a provider API). The decorator prefixes the provider's message with '[Error] ->' and re-raises UnauthorizedError with the original traceback, preserving the specific class so callers can distinguish auth failures from other errors.

Source

Thrown at openbb_platform/core/openbb_core/app/static/utils/decorators.py:94

                        ]
                    )
                    msg = err.get("msg", "")
                    _input = (
                        "..."
                        if msg == "Missing required argument"
                        else err.get("input", "")
                    )
                    prefix = f"[Data Model] {e.title}\n" if "Data" in e.title else ""
                    error_list.append(
                        f"{prefix}[Arg] {loc} -> input: {_input} -> {msg}"
                    )
                error_list.insert(0, validation_error)
                error_str = "\n".join(error_list)
                raise OpenBBError(f"\n[Error] -> {error_str}").with_traceback(
                    tb
                ) from None
            if isinstance(e, UnauthorizedError):
                raise UnauthorizedError(f"\n[Error] -> {e}").with_traceback(
                    tb
                ) from None
            if isinstance(e, EmptyDataError):
                raise EmptyDataError(f"\n[Empty] -> {e}").with_traceback(tb) from None
            if isinstance(e, OpenBBError):
                raise OpenBBError(f"\n[Error] -> {e}").with_traceback(tb) from None
            if isinstance(e, Exception):
                raise OpenBBError(
                    f"\n[Unexpected Error] -> {e.__class__.__name__} -> {e}"
                ).with_traceback(tb) from None

        return None

    return wrapper

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Verify the API key is correct and active: obb.user.credentials.<provider>_api_key
  2. Confirm the key's plan covers the requested endpoint (upgrade plan or use a different endpoint/provider)
  3. Rotate/regenerate the key at the provider's website and update it in OpenBB settings
  4. Switch to a provider whose credentials work: same command with provider='yfinance' where applicable

Example fix

# before
obb.user.credentials.fmp_api_key = 'stale-key'
res = obb.equity.price.historical('AAPL', provider='fmp')

# after
obb.user.credentials.fmp_api_key = 'valid-key'
res = obb.equity.price.historical('AAPL', provider='fmp')
Defensive patterns

Strategy: try-catch

Try / catch

from openbb_core.provider.abstract.error import UnauthorizedError

try:
    res = obb.equity.price.historical('AAPL', provider='fmp')
except UnauthorizedError:
    obb.user.credentials.fmp_api_key = fetch_fresh_key()
    res = obb.equity.price.historical('AAPL', provider='fmp')

Prevention

When it happens

Trigger: Calling a command with provider='fmp' when the fmp_api_key is invalid, expired, or has no entitlement for the endpoint; provider returns 401/403 during the fetch step of the fetcher.

Common situations: Typo'd or revoked API key; free-tier key hitting a premium endpoint; key set for the wrong provider; key configured but environment variable not loaded; key quota exhausted leading to 403.

Related errors


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