0

I have this code below with my credentials;

from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.adobjects.campaign import Campaign

my_app_id = ''
my_app_secret = ''
my_access_token = ''
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
my_account = AdAccount('')
my_campaign = Campaign('')

When I run the code below, I get an error.

Input:

my_account_insights = my_account.get_insights()
print(my_account_insights)

Output:

FacebookRequestError: 

  Message: Call was not successful
  Method:  GET
  Path:    https://graph.facebook.com/v12.0/act_2193000197632450/adsets
  Params:  {'summary': 'true'}

  Status:  400
  Response:
    {
      "error": {
        "message": "(#100) Missing permissions",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "AvMDtZu8KYqYG8qt3repNjL"
      }
    }

What am I missing? Could you please help me to figure it out?

eduardosteps
  • 151
  • 1
  • 7

1 Answers1

-1

Generate a new token https://developers.facebook.com/tools/explorer/ and set the permission accordingly

Aaron
  • 1
  • 1
  • Mind adding which permissions are required? – dacx Nov 07 '21 at 11:06
  • @dacx I have "read_insights", "ads_management", "ads_read" enabled. – Aaron Nov 08 '21 at 13:05
  • Does this work for you when developing, or do you need to submit the app for review in order to request a proper access token? – dacx Nov 09 '21 at 08:41
  • @dacx My reporting app hasn't been submitted but I think it largely depends on the permissions you need. The ones I listed before were in 'standard access' mode and didn't require anything more. But if you want to access accounts that your PAGE has access to then yes, you'll need to request a token in an initial call and save it as a variable to then include in this call. – Aaron Nov 10 '21 at 09:26