Unable to post to facebook page using app token

3.4k views Asked by At

I am building my first facebook app and am facing a issue.

Task : Build a entirely server side application to be used by the admin of a facebook page to post videos/photos on the page. This should not involve having the admin to log in everytime to generate the user acess and page access token.

What I found : Based on the requirement, I found that app tokens can be used for this purpose. This line specifically hints at the usefulness.

App access tokens can also be used to publish content to Facebook on behalf of a person who has granted an open graph publishing permission to your application

I think that using this will be safe since mine is an entirely server side app.

Problem The docs say that:

GET /oauth/access_token? client_id={app-id} &client_secret={app-secret} &grant_type=client_credentials

will give the app token that can be used in place of user access token. However, I have not been able to do so. Specifically the error encountered is Error 200 .The user must have accepted the TOS. Since I have already tried publishing content with page access token, I know this is a permission issue.

The following line

a person who has granted an open graph publishing permission to your application.

does not clarify everything. I came across a related question, but the answers seem to be a bit vague.

It would be really great if someone could give me insights about how this can be achieved.

2

There are 2 answers

4
andyrandy On BEST ANSWER

In order to post to a page, you need at least authorize with the manage_pages permission. If you want to post "as user", you need to add publish_actions and use a "User Access Token". If you want to post "as page", you need to add publish_pages and use a "Page Access Token".

Information about how to generate those Tokens:

The error message with the TOS has been discussed a lot of times already, please go to those threads (or find a lot more with the search function):

2
Tobi On

You cannot post to a Page via an App Access Token. This is clearly stated in the docs at

  • A user access token with publish_actions permission can be used to publish new posts on behalf of that person. Posts will appear in the voice of the user.
  • A page access token with publish_pages permission can be used to publish new posts on behalf of that page. Posts will appear in the voice of the page.

I'd recommend to use a eternal Page Acess Token, so there's no obligation to renew the User Access Token. Have a look at my answer here:

See