6

I am trying to get a page access token of a facebook page using its graph api for posting anything in that page.

From https://developers.facebook.com/tools/explorer I can get the page access token and then I can post on the page using it.

I go through all the similar question answer of stack overflow. but failed.

Here is my details flow

  1. Firstly for code - my_code
    http://www.facebook.com/dialog/oauth?client_id=&redirect_uri=&scope=email

  2. I get the user_access_token going through this

    https://graph.facebook.com/oauth/access_token?client_id=my_app_id&client_secret=my_app_secret&redirect_uri=my_redirect_url&code=my_code

  3. Then for long lived token

    https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=my_app_id&client_secret=my_app_secret&fb_exchange_token=my_user_access_token

  4. After getting the my_user_access_token_long I request for page access token

    https://graph.facebook.com/me/accounts?access_token=my_user_access_token_long

    it returns

    {"data":[]}

    If I try https://graph.facebook.com/my_page_id?fields=access_token&access_token=my_access_token_long

    it returns only my page id

    { "id": "my_page_id" }

Please help me to solve this issue. Thanks in advance.

2 Answers2

3

You need to add manage_pages permission in the first step

http://www.facebook.com/dialog/oauth?client_id=&redirect_uri=&scope=email,manage_pages

See Page Access Tokens in the documentation.

phwd
  • 19,975
  • 5
  • 50
  • 78
  • Thank you phwd I got now Page Access Token. But now I am getting forbidden while I am posting anything on the page. While getting me/accounts I am having this permission for the page `"perms":[ "ADMINISTER", "EDIT_PROFILE", "CREATE_CONTENT", "MODERATE_CONTENT", "CREATE_ADS", "BASIC_ADMIN" ]` – Arafat Rahman PAppu Jan 27 '16 at 13:04
0

I don't see this critical page being mentioned:

Manually Build a Login Flow

This shows the whole required OAuth flow, and how to exchange a temporary code after the user authenticates, with a final longer-term access token (from what I am seeing, with an expiration at this time of ~ 60 days).

Nicholas Petersen
  • 9,104
  • 7
  • 59
  • 69