Due to ongoing changes in Facebook API caused by Cambridge Analytica data leak, apps have lost access to public posts & event API. Hence no posts or events are returned when using an app access token, if the app is not verified by Facebook.
As a solution, never expiring page access token can be retrieved as per the instructions listed in the following steps.
- User needs to be both page admin and the app admin.
- Page access token will be invalidated if the user (admin) changes his/her password.
- Sign up for Facebook developers portal and create a new app. (You can skip this step if you already have an app)
2. Go to Dashboard → Settings → Basic and copy the App ID and App Secret.
3. Navigate to Facebook Graph API Explorer, to generate short-lived access token.
- Select your app from Application drop-down.
- In the next drop-down select Get user access token.
- Now you will see a pop-up window like below. There you will be able to select the permission(scopes) for the user access token.
pages_show_listpermissions. If you would like to understand more about the permissions visit permissions documentation
- Generate user access token by clicking on “Get Access Token” button. This will open a popup where you need to select the relevant page you manage.
- After clicking
Nextit will display the confirmation page with the requested permissions.
Done. This will create short-lived user access token.
4. Navigate to Access Token Tool, and click debug button at right side of the user access token for the current app (for which we are trying to create a long-lived access token)
5. This will navigate you to Access Token Debugger, where you will see the full information for the short-lived user access token. Note that short-lived user access token expires after an hour.
6. To extend the expiry date, Click on Extend Access Token at the bottom of the page and you will get the long-lived access token. Copy this new long-lived access token to use in the next step.
Note: If you don’t see the “Extend Access Token” button and your token expires in two months, that means you already have the
long-lived access token. You can skip this step and go to step 7.
7. Now, go to Graph API Explorer and paste the recently created long-lived user access token in the Access Token field. You need to change the API endpoint to access
/me/accounts and click on Submit button. This process will show the result with all pages information including page access token i.e never expiring token. Copy the access token of the relevant page.
8. Now you can verify if the page access token is never expiring. Go to Access Token Debugger and paste the never expiring access token you received from the above step and click Debug.
By following the above steps, you will be able to get a never-expiring page access token which you can use with your own page integrations.