How to get Facebook Page Access Token
In this guide I will know how to get a Facebook Page Access Token.
Create Facebook App
- Go to developer page https://developers.facebook.com/apps
- Click a button Create App.
- On the form select an app type. Let it be Business.
- Press a button Next.
- Enter App name in display name field. It can be any.
- The same with a contact email field.
- After press a button Create App.
Than you will be redirected on App Dashboard.
- Navigate to the Setting -> Basic
- Remember App ID and App secret. We will use it in the next steps.
Generate a Short-lived User Access Token
After navigate to Facebook Graph Explorer. This tool helps us to get user and page access tokens.
First of all we need to get the user short-lived access token.
- Select an earlier created App in Facebook App list.
- Select Get User Access token in User or Page list.
- After you will see Facebook Login page. Follow Facebook instruction.
- If everything is fine you will get a short-lived access token in the Access Token field. Copy it.
Generate a Long-lived User Access Token
When we get a Short-lived access token, we can get a Long-lived access token for the user. Below you can see an URL that should be modified. Paste your APP-ID, APP-SECRET from the App Dashboard and Access Token that was earlier generated with Facebook Graph Explorer.
https://graph.facebook.com/ oauth/access_token?grant_type=fb_exchange_token& client_id=APP-ID& client_secret=APP-SECRET& fb_exchange_token=SHORT-LIVED-USER-ACCESS-TOKEN
- Copy modified URL wihout https://graph.facebook.com/ and paste it to the Adress field on Facebook Graph Explorer.
- Click Submit
- After if an URL is correct you will get Long-lived access token for the user. Copy it.
Generate a Long-lived Page Access Token
Now we have a Long-lived user access token. It must be used to get a Long-lived Page Access Token.
- Copy URL path
me?fields=accountsand paste it to the Adress field.
- Copy your Long-lived user access token and paste it to the Access Token field.
- Select your Facebook App
- Check that Permissions. Permissions
pages_read_engagementmust be present. If it is false add them.
- Press the button Submit
- If everything is corectly configured you will get a response. Find an
access_tokenfield and copy it.