Posted on 2:58 AM by Softminer and filed under

How to generate long life access token

1. First you need to create an App, for creating app go to https://developers.facebook.com

From menu App, choose Add a new app

when you created app you will have a App ID and App Secret key

2. Gerenerating short access token which is 1 hour valid
From menu choose Tools -> Access Token
then you have the "User Token"

3. Call facebook Api
Go to Tools-> Graph API explorer
for example /me?fields=id,name
would be https://graph.facebook.com/me?fields=id,name&access_token={access_token}

4. To generate 2 months valid access token, use following get request

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-token}

app-id you get from step 1
app-secret you get from step 1
short-lived-token you get from step 2

5. Long life valid token

related links +

Responses to ... Long life access token in Facebook API