Search code examples
facebook-graph-apifacebook-appsfacebook-access-tokenfacebook-ads-api

Use App Access Token for ads stats?


I need to access Facebook API to retrieve ads stats. All my requests will be handled on server side. I already know how to access those data by obtaining User Access Token with ads_read permission, where user has admin role in the ad account.

My application will use cron jobs to retrieve ads stats, so I would like to use App Access Token instead, because user won't need to authenticate with the dialog, right? I assigned application to the business, but it doesn't seem to work. After trying to get ads stats with App Access Token, I'm getting following error:

{
  "error": {
    "message": "The entity backed by id 1234567890123 cannot be seen
                by the viewer with (ViewerID 0, AccountID 0):
                DENY_RULE:InlinePrivacyPolicy:AlwaysDenyRule:4
                (EntID: 1234567890123)", 
    "type": "OAuthException", 
    "code": 1
  }
}

The application is assigned to the business, but I'm not sure if it's enough. I don't see any option to assign it to the ads account.

Am I doing it right or maybe there's another way to skip dialog part?


Solution

  • No, you need to use a user access token from a user who manages the ad account.

    App access tokens are only useful for a narrow range of use cases, primarily for updating app settings or proving a call came from the app specifically, rather than an arbitrary user of the app