Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get page access token Facebook graph api via calling the get request, java

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.

like image 395
Arafat Rahman PAppu Avatar asked Jan 26 '16 08:01

Arafat Rahman PAppu


1 Answers

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.

like image 160
phwd Avatar answered Oct 08 '22 18:10

phwd