I'm running into an issue when trying to fetch data from a Facebook ad account via the Marketing API.
- I’m using a long-lived user access token created by the account admin.
- The user associated with the token has full access in Business Manager.
- Previously, the request
/me/adaccountsworked and returned active accounts, but now it returns the error:
{'error': {'message': 'API access blocked.', 'type': 'OAuthException', 'code': 200, 'fbtrace_id': 'ANGfnFiboGN3X77OVXvprlu'}}
Example code causing the error:
import requests
access_token = "..."
url = "https://graph.facebook.com/v23.0/me/adaccounts"
params = {"access_token": access_token}
response = requests.get(url, params=params)
print(response.json())
I also tried fetching dashboard data via /insights for a specific ad account, but get the same error:
import requests, json, pandas as pd
access_token = "..."
ad_id = "act_7167..."
url = f"https://graph.facebook.com/v23.0/{ad_id}/insights"
time_range = json.dumps({"since":"2025年01月01日","until":"2025年09月01日"})
params = {
"access_token": access_token,
"time_range": time_range,
"level": "ad",
"fields": "date_start,date_stop,spend,impressions,frequency,cpc,ctr",
"breakdowns": "country",
"time_increment": 1
}
response = requests.get(url, params=params)
data = response.json()
if "error" in data:
print("Error:", data["error"])
else:
df = pd.DataFrame(data["data"])
print(df.to_string())
Why does a valid long-lived user token still fail for /me/adaccounts and /insights?
-
1Are you saying with a short-lived token everything works as it should?C3roe– C3roe2025年09月24日 08:47:21 +00:00Commented Sep 24, 2025 at 8:47
-
1Did you manage to fix it? I am having the same problem and don't know why..T-Dog– T-Dog2025年12月04日 08:57:28 +00:00Commented Dec 4, 2025 at 8:57
lang-py