Steps to create never expiring Facebook access token
Categories:
less than a minute
- Open Graph API Explorer https://developers.facebook.com/tools/explorer
- Select the required application in the “Facebook App” drop-down menu
- Select “Get User Access Token” under “User or Page” (this opens a popup)
- In the popup, grant access from a Facebook account that has access to manage the target pages (This popup will flash and disappear if permissions are already granted)
- Make sure “manage_pages” and “publish_pages” (optionally pages_show_list) are selected under “Add a Permission”, if not select them
- Click “Generate Token”
- Copy the token that appears in the “Access Token” field (which is your short-lived access token)
- Invoke the following URL which gives long lived token (expires in 2 months): 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_from_previous_step}
- Copy the access token for the required page
- Invoke the following url which gives never expire token https://graph.facebook.com/{page-id}?fields=access_token&access_token=
- Validate the token using https://developers.facebook.com/tools/debug/accesstoken={token-from-previous-step}
- Note:
- Expires will have value Never and Data Access Expires will have 3 months, do not worry about Data Access Expires, because manage/publish pages permission will not expire though the Data Access expires
- Make sure validator show Valid as True