This has helped me and I hope will help someone else too one day.
These are the steps to achieve campaign list after oAuth.
Step 1 (Front-end):
Do authentication frontend side with following URL:
https://www.facebook.com/v3.0/dialog/oauth?client_id=<client_id>&redirect_uri=<URL>&scope=email%2Cads_management%2Cads_read&response_type=code&state=<state>
Step 2 (Front-end + Backend):
Step 1
will give code
object, pass it to backend
Step 3 (Backend):
Fetch access-token
of user using following API
https://graph.facebook.com/v10.0/oauth/access_token?client_id=<client_id>&redirect_uri=<redirect_URL>&client_secret=<client_secret>&code=<code-from-front-end>
Step 4 (Backend):
Fetch Ads account details:
https://graph.facebook.com/v10.0/me/adaccounts?access_token=<access_token_from_step_3>
Step 5 (Backend):
Fetch Campaigns list:
https://graph.facebook.com/v10.0/act_<account_id_from_step_4>/campaigns?access_token=<access_token>&fields=id,name,objective,configured_status,effective_status,account_id,bid_amount,bid_strategy,start_time,end_time,targeting,daily_budget,campaign_id,special_ad_categories
Here you will get Campaign list of authorized user.
Note:
- If your facebook app is under development mode then make sure you added authenticating user in your
Admin/Developer/Tester
list
- Make sure authenticating account is having Campaigns