facebook: permanent Page Access Token?

I work on a project that has facebook pages as one of its data sources. It imports some data from it periodically with no GUI involved. Then we use a web app to show the data we already have.

Not all the information is public. This means I have to get access to the data once and then keep it. However, I don't know the process and I haven't found a good tutorial on that yet. I guess I need an access_token , how can I get it from the user, step by step? The user is an admin of a facebook page, will he have to add some FB app of ours to the page?

EDIT: Thanks @phwd for the tip. I made a tutorial how to get a permanent page access token, even with offline_access no longer existing.

EDIT: I just found out it's answered here: Long-lasting FB access-token for server to pull FB page info


Following the instructions laid out in Facebook's extending page tokens documentation I was able to get a page access token that does not expire.

I suggest using the Graph API Explorer for all of these steps except where otherwise stated.

0. Create Facebook App

If you already have an app , skip to step 1.

  • Go to My Apps.
  • Click "+ Add a New App".
  • Setup a website app.
  • You don't need to change its permissions or anything. You just need an app that wont go away before you're done with your access token.

    1. Get User Short-Lived Access Token

  • Go to the Graph API Explorer.
  • Select the application you want to get the access token for (in the "Application" drop-down menu, not the "My Apps" menu).
  • Click "Get Token" > "Get User Access Token".
  • In the pop-up, under the "Extended Permissions" tab, check "manage_pages".
  • Click "Get Access Token".
  • Grant access from a Facebook account that has access to manage the target page. Note that if this user loses access the final, never-expiring access token will likely stop working.
  • The token that appears in the "Access Token" field is your short-lived access token.

    2. Generate Long-Lived Access Token

    Following these instructions from the Facebook docs, make a GET request to

    https://graph.facebook.com/v2.10/oauth/access_token?grant_type=fb_exchange_token&client_id= {app_id} &client_secret= {app_secret} &fb_exchange_token= {short_lived_token}

    entering in your app's ID and secret and the short-lived token generated in the previous step.

    You cannot use the Graph API Explorer . For some reason it gets stuck on this request. I think it's because the response isn't JSON, but a query string. Since it's a GET request, you can just go to the URL in your browser.

    The response should look like this:

    {"access_token":" ABC123 ","token_type":"bearer","expires_in":5183791}

    "ABC123" will be your long-lived access token. You can put it into the Access Token Debugger to verify. Under "Expires" it should have something like "2 months".

    3. Get User ID

    Using the long-lived access token, make a GET request to

    https://graph.facebook.com/v2.10/me?access_token= {long_lived_access_token}

    The id field is your account ID. You'll need it for the next step.

    4. Get Permanent Page Access Token

    Make a GET request to

    https://graph.facebook.com/v2.10/ {account_id} /accounts?access_token= {long_lived_access_token}

    The JSON response should have a data field under which is an array of items the user has access to. Find the item for the page you want the permanent access token from. The access_token field should have your permanent access token. Copy it and test it in the Access Token Debugger. Under "Expires" it should say "Never".


    Here's my solution using only Graph API Explorer & Access Token Debugger:

  • Graph API Explorer:
  • Select your App from the top right dropdown menu
  • Select "Get User Access Token" from dropdown (right of access token field) and select needed permissions
  • Copy user access token
  • Access Token Debugger:
  • Paste copied token and press "Debug"
  • Press "Extend Access Token" and copy the generated long-lived user access token
  • Graph API Explorer:
  • Paste copied token into the "Access Token" field
  • Make a GET request with "PAGE_ID?fields=access_token"
  • Find the permanent page access token in the response (node "access_token")
  • (Optional) Access Token Debugger:
  • Paste the permanent token and press "Debug"
  • "Expires" should be "Never"
  • (Tested with API Version 2.9-2.11)


    In addition to the recommended steps in the Vlasec answer, you can use:

  • Graph API explorer to make the queries, eg /{pageId}?fields=access_token&access_token=THE_ACCESS_TOKEN_PROVIDED_BY_GRAPH_EXPLORER
  • Access Token Debugger to get information about the access token.
  • 链接地址: http://www.djcxy.com/p/54114.html

    上一篇: 在没有JS SDK的情况下获取Facebook登录状态和签名请求

    下一篇: Facebook:永久页面访问令牌?