In this text, you will learn how to create an access token for your Facebook application. This token can be used to download information such as likes or comments from Facebook and allows people to work with this information without logging in to Facebook.
To obtain an access token, you need to register as a Facebook Developer by filling in the registration form: https://developers.facebook.com/async/registration. Make sure you are logged in to the account you use to manage your page.
Generating an access token
Go to https://developers.facebook.com/tools/explorer/. Log in to your account if needed.
Select the app you want to work with, either by its name (for example, Sirius) or ID (for example, 380469262752699). (If you manage multiple Facebook apps, you can check which app is selected in the Meta App menu on the right side of the page.)
Click the Generate Access Token button. A new window will open in which you need to log in to Facebook.
Next, select Get Page Access Token from the User or Page menu. Again, a new window will open. First, confirm your login (enter your password, if needed), then approve or select what Facebook page should be used. In the next step, agree to the required permissions (Read content posted on the Page, Show a list of the Pages you manage) and, in the last step, confirm everything by clicking OK.
The next step is to add the permissions to access user comments using the generated token: in the Permissions menu, specifically in the Add a Permission field, enter pages_read_user_content or select this permission from the drop-down menu.
When you add the permission, you need to select your Facebook page again. You can find it under Page Access Tokens in the User or Page menu.
Next, copy the access token using the Copy Token button on the top right of the page.
Token validation
To verify that the token you created is valid, go to https://developers.facebook.com/tools/debug/accesstoken/. (Again, you must be logged in to your Facebook account.)
Paste the token you copied in the previous step into the text box and click the Debug button.
A table with token information similar to the image below will appear. (The page name or user information will be different, of course.)
The generated token is valid for approximately 60 minutes. You create it to check that everything is in order – if so, it is possible to generate a token with extended validity.
Generating an extended access token
Re-generating the token
Return to https://developers.facebook.com/tools/explorer/ and check or add the permissions you have set in the Permissions menu.
The required permissions are:
pages_show_list
pages_read_engagement
pages_read_user_content
public_profile
read_insights
After checking the permissions, select Return to User Token or User Token in the User or Page menu.
Next, click on Generate Access Token, same as when you first generated the token, i.e. confirm the login, select which Facebook page to use, agree to the required permissions and confirm everything with OK.
Verify that the User Token is selected in the User or Page menu. Copy the token (by clicking the Copy Token button).
Extending the token validity
Go to https://developers.facebook.com/tools/debug/accesstoken/ again, enter the token in the text box and click Debug. Again, the table with token information is shown.
Click on the Extend Access Token button below the table. A new window will open where you enter your password. Then a new token will appear at the bottom of the page, with a Debug button next to it.
When you click this button, the table appears again; however, the expiration date is extended to two months (see the Expires row).
Next, copy the generated token.
Creating a token with unlimited validity
Return to https://developers.facebook.com/tools/explorer/ and paste the extended access token into the Access Token field. (You need to actually paste the new token, do not click the Generate Access Token button.)
Select your page in the Users or Page menu (under Page Access Tokens). The access token value will change. Copy the new token (using the Copy Token button) and check it again at https://developers.facebook.com/tools/debug/accesstoken/ (paste the token into the text box, and click Debug).
A table similar to the one below will be created; the value in the Expires row should change to Never.
If everything fits, the token is ready, and you can pass it on or save it for later use.

