Search code examples
node.jsfacebookfacebook-graph-apifacebook-javascript-sdkfacebook-marketing-api

Cannot retrieve ad accounts from Facebook Graph API for user who has authorized with `ads_read` permission


I have a user that is able to authorize with Facebook on our app using the ads_read permission, but when we attempt to get ad accounts from this user's account using the <USER_ID>/adaccounts edge on the Facebook Graph API, it returns an error:

{
  error: {
    message: "Unsupported get request. Object with ID '<USER_ID>' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
    type: 'GraphMethodException',
    code: 100,
    error_subcode: 33,
    fbtrace_id: 'A3UCn8GlZiw9s3MRFG8sDUx'
  }
}

I found a similar question in the Facebook Community, but it's from Graph API version 3. https://developers.facebook.com/community/threads/489913344898099/

Why am I unable to retrieve the ad accounts for this user?

I'm using a regular GET request to the Graph API using fetch from a Node.js server to retrieve this data.

      fetch(
        `https://graph.facebook.com/v10.0/${<USER_ID>}/adaccounts?fields=name,id,account_id&access_token=${<ACCESS_TOKEN>}`,
        {
          method: "GET"
        }
      )
        .then((_res) => _res.json())
        .then((accounts) => {
        // ... do stuff with ad accounts
      })


Solution

  • Try with ads_management permission.

    Based on FB docs, I guess permission that associated with /adaccounts is ads_management. While ads_read is related to read ad report like Insight API.