Skip to content

Instantly share code, notes, and snippets.

@RohitRox
Created April 19, 2013 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RohitRox/5423027 to your computer and use it in GitHub Desktop.
Save RohitRox/5423027 to your computer and use it in GitHub Desktop.
fb access tokens
Fortunately, if you are trying to get the stream of a Facebook Page, there IS a better way. And one to get access tokens that never expire for pages.
Note: You need to A) be logged into FB, and B) be an admin for the page for which you are trying to get the stream.
1. Create an app on FB for your website. After creating it, make sure toe add your domain to App Domains and check Website with Facebook Login underneath “Select how your app integrates w FB” and provide your Site URL (which will be the oauth redirect_uri).
2. Visit the following to generate a new SHORT-LIVED (1 hour) access token:
https://www.facebook.com?
client_id=[APPID]&
client_secret=[APPSECRET]&
redirect_uri=[http://APPURL]&
scope=manage_pages,read_stream&
response_type=token
3. Take that short-lived access token and send it here:
https://graph.facebook.com/oauth/access_token?
client_id=APP_ID&
client_secret=APP_SECRET&
grant_type=fb_exchange_token&
fb_exchange_token=EXISTING_ACCESS_TOKEN
4. Then, either in FB’s Graph API Explorer or on your own, visit here:
https://graph.facebook.com/me/accounts
This last step will include all of the pages for which you are an admin along with their AppIDs and Access Tokens. These tokens will not expire (you can verify using the Debug button in FB’s Graph API Explorer)
BOOM! YMMV.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment