Facebook Access Token for Pages

181,709

Solution 1

  1. Go to the Graph API Explorer
  2. Choose your app from the dropdown menu
  3. Click "Get Access Token"
  4. Choose the manage_pages permission (you may need the user_events permission too, not sure)
  5. Now access the me/accounts connection and copy your page's access_token
  6. Click on your page's id
  7. Add the page's access_token to the GET fields
  8. Call the connection you want (e.g.: PAGE_ID/events)

Solution 2

See here if you want to grant a Facebook App permanent access to a page (even when you / the app owner are logged out):

http://developers.facebook.com/docs/opengraph/using-app-tokens/

"An App Access Token does not expire unless you refresh the application secret through your app settings."

Solution 3

The documentation for this is good if not a little difficult to find.

Facebook Graph API - Page Tokens

After initializing node's fbgraph, you can run:

var facebookAccountID = yourAccountIdHere 

graph
.setOptions(options)
.get(facebookAccountId + "/accounts", function(err, res) {
  console.log(res); 
});

and receive a JSON response with the token you want to grab, located at:

res.data[0].access_token
Share:
181,709
Rafael 'BSIDES' Pereira
Author by

Rafael 'BSIDES' Pereira

Senior Frontend Web Developer for a very long time, design enthusiast, iOS development student and love to learn the new stuff. I prefer to work with JavaScript, HTML/CSS, React, Nextjs and tools alike - but I've been engaged in projects with Angular, AngularJS, Vue, React Native and so on. I give lots of value in contributing and safe environments to work. Also like to play games online, preferably MMORPGs. I made a tool to measure your DPS/HPS in ACT for FFXIV. If you understood all this line, check it out: H O R I Z O V E R L A Y

Updated on October 21, 2020

Comments

  • Rafael 'BSIDES' Pereira
    Rafael 'BSIDES' Pereira over 3 years

    I have a Facebook Page that I want to get some things from it. First thing are feeds and from what I read they are public (no need for access_token). But I want to also get the events... and they aren't public and need the access_token.

    I don't want the user to login in Facebook or anything like that. I just want to push all the data I can from this only page. That's why I already discarded many examples I found here and the one at https://developers.facebook.com/blog/post/500/ , because they want the user to login or require some user action I'm not interessed.

    What I want is that my Facebook Application have full authorization and access_token to push the data from this one Facebook Page that I own (admin). Is this possible? I already tried many things but nothing seems to work.

    I tried clicking at this: https://www.facebook.com/dialog/oauth?client_id=150635421702954&redirect_uri=http://MY_URL/&scope=manage_pages&response_type=token&fields=access_token - changing MY_URL to my site's and it requests authorization to edit every page I own. Even not being what I want I clicked but had no access_token in return...

  • andresp
    andresp over 11 years
    By doing this I'm able to call connections on all my pages by using a page token of only one of them. Isn't this wrong? Is there a way to get a token for just one specific page that doesn't work on the other pages?
  • IMB
    IMB over 11 years
    I've climb mountains and swim oceans just seek for this answer. Thank you.
  • coneybeare
    coneybeare over 11 years
    This process doesn't work anymore as the access token generated expires when you log out for whatever reason.
  • ifaour
    ifaour over 11 years
    @coneybeare, please refer to this document on how to extend the page access token
  • Sinan
    Sinan over 11 years
    This does not help with getting events for a restricted page.
  • Keyur Mistry
    Keyur Mistry about 10 years
    I am not able to see the 3 rd point, that is (Get Access Token). So can you please tell me the process, to get token, and active it out.?
  • Max
    Max almost 10 years
    I keep getting an empty result. Does it make a difference if it is an app page?
  • Grzegorz
    Grzegorz over 9 years
    As I wanted to say thank you I also want to add that this seems to be the only (at last one i found) way to obtain page access token.
  • GrantJ
    GrantJ almost 9 years
    This used to work for me but doesn't after April 30th.
  • ifaour
    ifaour almost 9 years
    @Tony, what doesn't work? what have you tried? and what do you want to achieve?
  • Antwan
    Antwan almost 9 years
    get a specific page public posts without user login using my app access token
  • ifaour
    ifaour almost 9 years
    @Tony, this should work for public posts, try this on cocacola/feed. Select your app from a dropdown, and then "Get App Token" and test.
  • almaruf
    almaruf almost 8 years
    I dont have a app for that page, so used a different add_id and secret with this pages auth token and got this "Invalid appsecret_proof provided in the API argument"
  • Nick Bondarenko
    Nick Bondarenko over 7 years
    @ifaour tnanx a lot for your answer!
  • PHP Ninja
    PHP Ninja over 6 years
    Hi. can i add a page post with user access token who is admin of the page? please help me
  • jeromej
    jeromej about 6 years
    Is that still true?!
  • Amade
    Amade about 6 years
    There is a way to make the token never to expire. Check this answer for reference: stackoverflow.com/a/39182923/4171578
  • Jesse Novotny
    Jesse Novotny over 5 years
    Sure, but how do I get ONE page's access token? At the moment, our app manages hundreds of pages. Using this method, we must make numerous requests until we get the access token for the right business.
  • albanx
    albanx about 5 years
    This does not work anymore, seems that there is not a way to publish to your own page with an api now.
  • Pedram
    Pedram almost 5 years
    Anyone have recently achieved this? I'm looking for this. Please help.
  • Aadam
    Aadam over 4 years
    I do not feel people are using facebook that much like before, any how they should provide simple solutions to access at least page likes
  • Masroor
    Masroor over 3 years
    a programmatic approach would have served better. This only helps for testing the API calls, but the real issue is how to do it with code.