I have read the fb docs and written code to publish a message to a facebook "page", however I am getting an error that I don't expect to see:
(#200) The user hasn't authorized the application to perform this action
Here's what I've done:
- I set up a facebook application, which provides my
APP_ID
andAPP_SECRET
. - I set up a test facebook "page". Let us refer to its fb id as
PAGE_ID
. - Used OAuth to get a
USER_ACCESS_TOKEN
with scope "publish_actions,manage_pages" for the user. I accepted the permissions requested by my app when redirected to the facebook auth page. - I did a GET on
https://graph.facebook.com/me/accounts
using theUSER_ACCESS_TOKEN
, and I get back a list of pages I administrate, including the one I want to post to.
This block of data for my page looks like:
{
"data": [
{
"category": "Community",
"name": "My Generic Test Page",
"access_token": PAGE_ACCESS_TOKEN,
"id": PAGE_ID,
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
....
]
}
Then I use the PAGE_ACCESS_TOKEN
to post a message to the page:
- I did a POST on
https://graph.facebook.com/PAGE_ID/feed
with a fieldmessage
equal toThis is a test post.
Facebook returns:
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException",
"code": 200
}
}
Using the token debugger, I can confirm that my PAGE_ACCESS_TOKEN
is valid, and has scopes: manage_pages
and publish_actions
.
Where am I missing authorizing the application? Do I need additional scopes? Did I miss clicking something on the facebook authorization screen? Is there a setting on the app I am missing? After days of debugging this, I must be blind to the problem. :-|