user1477388
user1477388

Reputation: 21440

Cannot Generate Page Access Token Using Facebook Graph API

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

Upvotes: 12

Views: 9402

Answers (4)

Dhruv Vagadia
Dhruv Vagadia

Reputation: 1

I encountered a similar issue where I couldn't find the pages_read_engagement and other page-related permissions.

To resolve this, I created a completely new app and selected the App Type: "Business". This allowed me to access all the necessary permissions. Please note that you should only select the Consumer type if you need basic login permissions and advertisement permissions

Upvotes: 0

Nick N.
Nick N.

Reputation: 13558

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

Upvotes: 16

user23458613
user23458613

Reputation: 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.

Upvotes: -1

Vivek
Vivek

Reputation: 1523

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.

Upvotes: 2

Related Questions