I wish there was a master key with access to all the data on Facebook; it will make the life of developers much easier; unfortunately, it won’t be secure.

So here is a crash course about Access Tokens.

There are three components to access tokens: 1) Users, 2) Facebook app, 3) Your app.

A user can grant permission to a Facebook app to access her data. The result of this permission is the access token. In your app, you can use th access token, and with the Facebook app ID and secret, you can access the user’s information.

Depending on what type of data you want, you have different types of access tokens: 1) User access token, 2) App access token, 3) Page access token.

The easiest to understand is the first one: it allows you to access the Facebook data of the person who gives you access. The second is not much of use. Once you create a new app, you can programmatically change its settings with the app access token.

The page access token is tricky. Because users own Facebook pages, you need permission from a user. Furthermore, your Facebook app by default don’t have access to Pages data, so you need to submit your app for review requesting this type of permission.

Fortunately, there is a particular type of user called “System user.” You can go to your Business Manager, then Business settings, and find the option under Users. It will allow you to generate a token for the system user, and then you can add the pages as asset.

If you don’t want to go through the app review process, you can use the Graph API Explorer, choose your app, and get the token for your Facebook page.

Accessing to the Marketing Ads API works in the same way: you need a user (real or system user) to have access to the Ad Accounts. Unlike Facebook Pages where you need a token per page, here you only need the system user access token.

In short: there are access tokens for a user, system users, pages and apps. An access token is generated between a user and an app. You can use the access token and your app credentials in your app to access the data the access token allows you to.

Leo Celis