I am using the Instagram Basic Display API OAuth flow to authenticate an Instagram account within my web application.
Once they have authenticated successfully, I am exchanging the short lived access token for a long lived one, code snippet below:
url = "https://api.instagram.com/oauth/access_token"
body = {
'client_id': CLIENT_ID,
'client_secret': CLIENT_SECRET,
'grant_type': 'authorization_code',
'redirect_uri': REDIRECT_URI,
'code': CODE
}
I have tested this for various Instagram Professional accounts. For some, I get a HTTP 200 response and I am able to get a long lived access token. But for others, I get the following response:
{
"error": {
"message": "Unsupported request - method type: get",
"type": "IGApiException",
"code": 100,
"fbtrace_id": "AtnOFqdYDJ9lDj2GgOwv7EE"
}
}
Researching on the internet this looks like a bug on Facebook's side, and that this happens somewhat randomly. Can someone please explain why this is happening and implement a fix as soon as possible? My application relies on users being able to authenticate using their Instagram Professional account and this bug is preventing critical features from working.

I created an app which uss facebook API for post and read content from facebook pages. App was recently approved, I can go live. Everything worked in test regime with test accounts, but when I started testing it live with real accounts I have en errors I cannot explain.

  1. I removed permission role as admin/tester from my fake test account, to test it as external. I can login with it and get page data. I can post on behalf of this user. But for some reason I cannot get feed. I receive an error, that I miss pages_read_engagement permission, but in my business app stated, that this permission is granted and active. And when I login, this permission is on the list, that I grant app with this data. I wrote already letter to facebook direct support, but didn't receive any reply yet. Any ideas?

  2. When I try to login with my personal facebook account, I can, I get user data, but I cannot get any pages data. Array with pages is returned empty. I do have pages_show_list permission. In this case there is no error calling this api, but why I cannot see any pages?

I will appreciate any advice

curl -G \   -d "fields=campaign_name,adset_id,adset_name,impressions,clicks,cpc,spend,date_start,date_stop" \   -d "time_range={'since':'2023-07-01','until':'2023-09-30'}" \   -d "access_token=${FACEBOOK_ACCESS_TOKEN}" \   https://graph.facebook.com/v21.0/act_"$FACEBOOK_ACCOUNT_ID"/insights 

Returns

{   "data": [     {       "impressions": "*******",       "clicks": "*****",       "cpc": "*****",       "spend": "**********",       "date_start": "2023-09-25",       "date_stop": "2023-09-30"     }   ],   "paging": {     "cursors": {       "before": "****",       "after": "****"     }   } } 

Why is it not returning the other fields like campaign_name, adset_id etc?? I'm getting the field names from here: https://github.com/facebook/facebook-php-business-sdk/blob/7ec7292c1ce3c78e2005d730da0092e28458af95/src/FacebookAds/Object/Fields/AdsInsightsFields.php#L46

If I make this call to get campaign data from the Graph API:

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=30&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`;  

I get 219,189 as the total reach. However, if I make the same call, changing only time_increment=7

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=7&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`; 

I get 287,141 as the total reach. If, finally, I change time_increment=1

const url = `https://graph.facebook.com/v19.0/${account}/insights?time_increment=1&time_range={since:'2024-01-01',until:'2024-01-30'}&level=campaign&fields=campaign_id,campaign_name,frequency,spend,reach,impressions,objective,optimization_goal,clicks,actions&action_breakdowns=action_type&access_token=${token}`;      

I get 391,900 as total reach. As we can see, these are very inconsistent figures. What could be the cause of this Thanks in advance!

Technical detail: I'm calling the data via the GET REST API method >> const data = await fetch(url). I'm not using an SDK.

I expect to recieve the same reach figure, independently of the time_increment parameter.