Cannot Generate Page Access Token Using Facebook Graph API
Asked Answered
S

3

9

I cannot seem to generate a page access token. I've tried using the Graph API Explorer by selecting "Get Page Access Token" from the User or Page dropdown, but it opens a window with the following error:

enter image description here

I've also tried sending the following API request but even though it returns a 200 OK status code, the content is an empty array!

curl -i -X GET "https://graph.facebook.com/{your-user-id}/accounts?access_token={user-access-token} 

Result:

{"data":[]}

I've also tried to get the page access token with the following command:

curl -i -X GET "https://graph.facebook.com/v14.0/<page_id>?access_token=<user_access_token>&fields=access_token"

Result:

{"error":{"message":"(#100) Object does not exist, cannot be loaded due to missing permission or reviewable feature, or does not support this operation. This endpoint requires the 'pages_read_engagement' permission or the 'Page Public Content Access' feature or the 'Page Public Metadata Access' feature. Refer to https://developers.facebook.com/docs/apps/review/login-permissions#manage-pages, https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS and https://developers.facebook.com/docs/apps/review/feature#page-public-metadata-access for details.","type":"OAuthException","code":100,"fbtrace_id":"AIx208__9nozhxypMyxZYpy"}}

My user is listed as the admin for this page and I previously was able to create page access tokens simply by using the Graph API Explorer above.

In the Graph API Explorer, I don't seem to have any such option for 'pages_read_engagement.'

enter image description here

How can I generate a page access token?

Note: I've also asked this question on the Facebook Developer Community Forum but no one has answered yet. This seems like a simple question so I'm surprised I've not gotten any responses thus far. https://developers.facebook.com/community/threads/911494286473743/

Ref. https://developers.facebook.com/docs/facebook-login/guides/access-tokens#pagetokens

Stringer answered 29/8, 2022 at 2:48 Comment(1)
Same issue here. No matter what I try, I cannot get it. I get the feeling it has something to do with the Meta Business center change, but that is just a hunch. Did you find any solution eventually?Ramiah
R
12

Ask for the business_management access permission. There is not a word about this in the docs, but it fixed it for me.

My problem started occurring after I became a full admin in meta business manager.

enter image description here

Ramiah answered 29/9, 2023 at 7:43 Comment(1)
This was changed in an out-of-cycle release and documentation hasn't been updated, but the release notes mention this change. Since Sept 15, 2023 this applied to v17 and later, but applies to all versions since Jan 23, 2024. developers.facebook.com/docs/graph-api/changelog/…Sometimes
W
2

If you're admin and you've Facebook Page ID of the page you need access token then you can use following API to fetch page access token -

curl --location --request GET 'https://graph.facebook.com/v14.0/<page_id>?access_token=<user_access_token>&fields=access_token'

You can also use Graph API Explorer to fetch the same using user token.

Waterlog answered 30/8, 2022 at 8:41 Comment(4)
Thanks for the response. The error I get is "(#100) Object does not exist, cannot be loaded due to missing permission or reviewable feature, or does not support this operation. This endpoint requires the 'pages_read_engagement' permission or the 'Page Public Content Access' feature or the 'Page Public Metadata Access' feature. Refer to https://developers.facebook.com/docs/apps/review/login-permissions#manage-pages...Stringer
Try to regenerate user token with required permission by adding missing permission from permissions tab just below user/app token selection. Hope this helps. :)Waterlog
The required permission, 'pages_read_engagement' does not seem to be included in the list (screenshot added above). Am I looking in the wrong place?Stringer
Same issue here, cannot get hold of the page tokenMonthly
I
-1

The problem you are facing is because you did not created Business app on Facebook developer account.

Delete your app and recreate a new Business App then try.

I will work for you.

Internalcombustion answered 21/2 at 19:23 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Inseparable

© 2022 - 2024 — McMap. All rights reserved.