OpenBB-finance/OpenBB · error · UnauthorizedError
Unauthorized FMP request -> {code} -> {msg}
Error message
Unauthorized FMP request -> {code} -> {msg} What it means
Raised in FMP's aiohttp response_callback whenever the HTTP status is not 200. It wraps any non-OK status (401/403 invalid key, 404 wrong endpoint, 429 rate limit, 5xx outage) as an UnauthorizedError with the status code and response body embedded, even though the actual cause may not be authorization.
Source
Thrown at openbb_platform/providers/fmp/openbb_fmp/utils/helpers.py:17
"""FMP Helpers Module."""
from datetime import date
from functools import lru_cache
from typing import Any
from openbb_core.app.model.abstract.error import OpenBBError
from openbb_core.provider.utils.errors import EmptyDataError, UnauthorizedError
from openbb_core.provider.utils.helpers import get_querystring
async def response_callback(response, _):
"""Use callback for make_request."""
if response.status != 200:
msg = await response.text()
code = response.status
raise UnauthorizedError(f"Unauthorized FMP request -> {code} -> {msg}")
data = await response.json()
if isinstance(data, dict):
error_message = data.get("Error Message", data.get("error"))
if error_message is not None:
conditions = (
"upgrade" in error_message.lower()
or "exclusive endpoint" in error_message.lower()
or "special endpoint" in error_message.lower()
or "premium query parameter" in error_message.lower()
or "subscription" in error_message.lower()
or "unauthorized" in error_message.lower()
or "premium" in error_message.lower()
)
if conditions:View on GitHub (pinned to 3e071fcc2c)
Solutions
- Read the embedded status code in the message: 401/403 means fix the api key, 429 means rate limit - slow down or upgrade, 404 means the endpoint moved, 5xx means retry later
- Verify the key with a trivial curl to https://financialmodelingprep.com/api/v3/profile/AAPL?apikey=KEY
- Ensure the credential is set in OpenBB (openbb.accountCredentials or FMP_API_KEY env var) and not truncated/quoted incorrectly
- For 429s, add request throttling in your own code or cache responses
Defensive patterns
Strategy: try-catch
Validate before calling
import requests
r = requests.get(f"https://financialmodelingprep.com/api/v3/profile/AAPL?apikey={api_key}")
assert r.status_code == 200, f'FMP key invalid or throttled: {r.status_code}' Try / catch
from openbb_core.provider.utils.errors import UnauthorizedError
try:
data = await fetcher.fetch_data(query, credentials)
except UnauthorizedError as e:
msg = str(e)
if '429' in msg:
await asyncio.sleep(60) # rate limited - back off and retry once
else:
raise # genuine auth/key problem Prevention
- Verify the FMP key with a trivial request at application startup
- Throttle FMP calls to stay under the plan's rate limit and cache responses
- Parse the embedded status code from the message to branch handling
When it happens
Trigger: Any FMP request through openbb_fmp.utils.helpers.get_data where FMP returns non-200: expired or malformed api_key, exceeding the free-tier rate limit, requesting a deprecated endpoint version, or FMP server errors.
Common situations: Wrong/placeholder FMP_API_KEY environment variable, free-tier keys hitting the per-minute/per-day request cap, stale endpoint URLs after FMP version changes, or transient 502/503s from FMP infrastructure.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- The temporary EconDB token could not be retrieved. Please tr
- The request was returned empty.
- [Error] -> {e}
- Method must be GET or POST
- methods must be a list of strings
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/a9f5010f90e55c15.
Report an issue: GitHub.