I apologise in advance if this question has been asked elsewhere or if it's a stupid question, but I'm desperate!
My goal
Create a POC which connects to a facebook sandbox ad account and tests what features are exposed in the API, such as uploading new video ads or creating ad campaigns.
The problem
I am following facebooks own getting started example for connecting with nodejs:
https://developers.facebook.com/docs/business-sdk/getting-started/#js
When i try to read from the AdAccount i get the following error:(#278) Reading advertisements requires an access token with the extended permission ads_read
Under Marketing API -> Settings, it is possible to submit a request to be granted access. I think..? This part confuses me a lot.
In order for me to grant my access token the right to make calls requiring the ads_read
permission, a human person at facebook must first grant me the right to grant this right to my access token?? (Please tell me if I got this wrong, it feels like that has to be wrong).
Chicken and the Egg?
As part of this proces i have to provide detailed instructions on reproducing the required need for permissions and a screencast of the process.
However all i have at this point is the sample code provided by facebooks example. And i don't plan on developing anything for this until i can at least get their sample working, which i can't without being granted access to ads_read
it would seem.
I must have misunderstood something
It seems obvious that i must have misunderstood something, but what?
Any help, clues, or link to guides that address this issue would be greatly appreciated. (Again i apologise if this question is very basic but I'm at the end of my rope here, thanks in advance)
In case anyone else is having the same problem i was, I feel it's appropriate to post how I managed to get the right token.
First off there is nothing wrong with the tutorial code here:
https://developers.facebook.com/docs/business-sdk/getting-started/#js
The hard part is to find the right token and give it access to make the calls used in the tutorial.
Assuming that you already have managed to create a Sandbox Ad Account you need to connect it to your business account here:
https://developers.facebook.com/apps/[APP-ID]/marketing-api/tools/?business_id=[BUSINESS-ID]
On this page there should be 4 buttons next to where the sandbox account is listed. One of them is a key with the caption "Get Access Token". This is the WRONG access token. (If anyone can elaborate on how/why please feel free). In order to get the access token you need to run the "Getting Started" sample you will need the ads_read permission.
Among the 4 buttons there should also be a suitcase with the caption "Connect to Business". If you do not see this button it either means you have no business or that you haven't attached a system user to your business (I think).
If the button is not there
Go to: https://business.facebook.com/settings/system-users?business_id=[BUSINESS-ID]
Create a system user and connect it to your App. Don't forget to set the permissions for that user.
If the button is there
Click the button and select your system user in the dropdown.
Then go to:
https://business.facebook.com/settings/system-users/[SYSTEM-USER-ID]?business_id=[BUSINESS-ID]
And click the Generate New Token button. Again don't forget to set the permissions for the token.
It may seem like a silly issue but it cost me almost a whole day myself so hopefully this could save someone else the time.
EDIT: I came across an access token debugger which could prove helpful to others with access token problems:
https://developers.facebook.com/tools/debug/accesstoken/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With