1

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/adaccounts worked 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?

asked Sep 23, 2025 at 18:45
2
  • 1
    Are you saying with a short-lived token everything works as it should? Commented Sep 24, 2025 at 8:47
  • 1
    Did you manage to fix it? I am having the same problem and don't know why.. Commented Dec 4, 2025 at 8:57

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.