Access token in Facebook Api

This tutorial help to understand Facebook access token type and use in Facebook api.Facebook provides two type access token taht can be used to get data from Facebook server using Facebook api.

There two type access token in Facebook api

1- App access token
2- User access token/Global access token.

App access token:

Authenticating as an App allows you to obtain an access token which allows you to make request to the Facebook API on behalf of an App rather than a User.
Each app has its own access token and user access token.
Expiry of token:
1- When we set offline access enabled on Facebook app setting then we will get token for 60 days.
2- Otherwise we will get app token for only 2 hours.

How to reset long term access token:

1- When we will change password or change app-secret key then automatically reset the app token.

To obtain an App Access Token, perform an HTTP GET on:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials

App token structure:
App-id | random characters

User Access token/Page access token:

To obtain page access token you need to authenticate as a User, and obtain a User Access Token. With help of this User Access Token you are able to get insights data as well as get post information with insights.

How to get User Access token:

https://graph.facebook.com/me/accounts?access_token=USER_ACCESS_TOKEN

Above request gives you all apps and pages with user access token.