Long Lived access token Facebook Page

VG108 picture VG108 · Jan 8, 2013 · Viewed 13.7k times · Source

I have a facebook page and i want the feeds of page. I am using graph api to get the access token but i have no idea how to convert that short-lived access token to long-lived access token

 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

If above link is used to get the long live access token then from where i can get App_Secret
Help Me if i am going on wrong approach.

Answer

Pragati Singh picture Pragati Singh · Jan 8, 2013

To get a long-lived access token you need to follow those steps:

  1. Create an Application

  2. Create a Page (your account need to be "administrator" of the page)

  3. Associate the application to the Page (the same way you do it when you want to add a Page Tab to a Page)

  4. Get a short-lived access token with the permission "manage_pages" associated to your Application.

  5. https://graph.facebook.com/oauth/authorize?client_id=APP_ID&scope=manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html

  6. then https://graph.facebook.com/oauth/access_token?client_id=APP_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=APP_SECRET&code=CODE_FROM_PREVIOUS_REQUEST

  7. Using the Graph API Explorer with the request /me/accounts you can see the access tokens for each Pages that you are administrator. The problem is that those access token are short-lived.

  8. Convert your short-lived access token to a long-lived (extending access token):

  9. https://graph.facebook.com/oauth/access_token?client_id=_APP_ID_&client_secret=_APP_SECRET_&grant_type=fb_exchange_token&fb_exchange_token=_ACCESS_TOKEN_ON_STEP_4_

    You can now test your new access token with the Access Token Debugger.