I need to create a Java app that stores ad names from a business account in a DB on a daily basis.
These are the steps taken:
-I was added to a business on Facebook with access to their ad accounts
-I registered an app on developers.facebook.com.
-Got the access token from https://developers.facebook.com/tools/debug/accesstoken/
- Got the app secret from the the apps panel
This is the code snippet:
public static final String ACCESS_TOKEN = [the token from above];
public static final Long ACCOUNT_ID = [the business account it];
public static final String APP_SECRET = [the scret from
public static void main(String...args) throws Exception {
APIContext context = new APIContext(ACCESS_TOKEN, APP_SECRET);
AdAccount account = new AdAccount(ACCOUNT_ID, context);
System.out.println(account.getAds().execute().getRawResponseAsJsonObject());
}
I get the following error:
com.facebook.ads.sdk.APIException$FailedRequestException: {"error":{"message":"(#273) This Ads API call requires the user to be admin of the ad account. User is not admin on ad account XXXXXXXX.","type":"OAuthException","code":273,"fbtrace_id":"GD30f+ON/k4"}}
I have the following questions:
1-Why do I need admin permission just to list the same ads I can see from the Ad Manager page?
2-What if my user losses access to the business account, but I want the Java to still function? Can other users still run the the Java code?
3-Is there anything wrong from the description and code above?
4-How can I generate a permanent token rather than a temporary one?