Posts tagged with instagram-api

My app is registered on facebook and has been live since the past 2 years. Now, i switched it to development mode since i need to integrate with "Instagram API with Facebook login".

So after following the documentation, https://developers.facebook.com/docs/instagram-platform/instagram-api-with-facebook-login/business-login-for-instagram , i linked my insta business account to one of my facebook pages using this link https://www.facebook.com/business/help/connect-instagram-to-page (Note : My facebook account has 2 pages)

I also linked the fb account to insta account by following this : https://help.instagram.com/176235449218188

I have added instagram under products section in my registered app in facebook. I have not confgured anything with respect to "API Setup with facebook login" there.

Now, iam trying to access /me/accounts to get all the pages data and instagram business account id by including scopes "instagram_basic" and "instagram_content_publish"

But iam not getting any data in graph API tool. It just returns

{   "data": [   ] } 

I have tried to debug, but couldnt figure it out. Iam stuck at this point. Any help would be appreciated,thanks.

i got the access token but while exhangeing it for long live token api getting following error

error: { message: 'Unsupported request - method type: get', type: 'IGApiException', code: 100, fbtrace_id: 'AnMYrIXYSTKYCA_Sh2qKxkU' }

const accessTokenApi = {             url: 'https://api.instagram.com/oauth/access_token',             method: 'post',             headers: {                 'Content-Type': 'application/x-www-form-urlencoded'             },             body: new URLSearchParams({                 code: code,                 redirect_uri: instagramConfig.callbackUrl,                 client_id: instagramConfig.clientId,                 client_secret: instagramConfig.clientSecret,                 grant_type: 'authorization_code',             }).toString(),         };         const tokenResponse = await this.apiCall(accessTokenApi); const userPlatform = await this.userPlatformService.getUserPlatfromsByCode(userId, "INSTAGRAM");         const userLongLiveTokenApi = {             url:`https://graph.instagram.com/access_token?grant_type=ig_exchange_token&client_secret=${instagramConfig.clientSecret}&access_token=${userPlatform.authToken}`,             method: 'get',             headers:{}         }         console.log(userLongLiveTokenApi)         const userLongLiveTokenResponse = await this.apiCall(userLongLiveTokenApi); 

I've encountered a problem with my application in Live mode. I've conducted several tests with various Facebook pages and Instagram accounts, always following the same process, but I'm getting inconsistent permissions.

I use facebook api v20.

Problem Details

  • In most cases, I successfully obtain all the required permissions.
  • In some instances, I can't get the pages_show_list permission.
  • The error occurs only with certain accounts, but I can't identify what distinguishes these accounts from the others.

Current Implementation

I'm requesting the following permissions:

  • instagram_basic
  • instagram_manage_insights
  • business_management
  • pages_show_list
  • pages_read_engagement

All permissions are successfully approved by facebook.

I use the following URL for authentication:

const url = `https://www.facebook.com/dialog/oauth?client_id=${CONFIG.FACEBOOK_APP_ID}&extras={"setup":{"channel":"IG_API_ONBOARDING"}}&redirect_uri=${CONFIG.BACKOFFICE_URL}/instagram&response_type=token&scope=instagram_basic,instagram_manage_insights,business_management,pages_show_list,pages_read_engagement` 

Encountered Error

When testing the user-generated accessToken in the Facebook API Graph Tester, I receive the following error, but only for some accounts:

"The "accounts" field is only accessible on the User object after the user has granted one of the following permissions: 'pages_show_list'." 

Questions

  1. How is it possible that this inconsistency in permissions occurs?
  2. Could it depend on some specific configuration of the Facebook page in question?
  3. What might be distinguishing the accounts that encounter this error from those that don't?
  4. Are there alternative solutions or approaches to ensure consistent obtaining of all required permissions?

Any help or suggestions to understand and resolve this issue would be greatly appreciated. Thank you in advance for your support.