This script was built to export Facebook Ads data to Google Sheets on a recurring basis for use in a dashboard.
In order to bypass limits around the amount of data that can be processed by the Facebook Marketing API and Google App Script's 6 minute runtime maximum, the script makes asynchronous requests to the Facebook Marketing API.
You'll first want to create a Facebook App and add the Marketing API product to it.
You can then get a short-lived user access token through the Graph API Explorer.
If you're going to be using this script on an ongoing basis, I recommend you exchange your short-lived token for a long-lived one using this method.
Once you've entered your credentials as well as all parameters, you'll want to make sure that request-facebook-report.js is scheduled to run before get-facebook-report.js.