...

/

Generate Access Token Using OAuth

Generate Access Token Using OAuth

Learn how to generate a Facebook access token.

We've completed the prerequisites of OAuth client registration for the application and retrieved the required credentials. Now, we'll use OAuth to get the required permissions from the client and then obtain the access token, which we'll use to fetch the user resources.

We'll use the authorization code grant workflow to generate the token. The workflow has been demonstrated in the figure below:

Press + to interact
Authorization code grant workflow
Authorization code grant workflow

The token generation process involves the following two endpoints:

  • https://www.facebook.com/v15.0/dialog/oauth is used to redirect the resource owner to Facebook's authorization server. The resource owner logs in using their Facebook ID and approves or denies the request to access their Facebook resources. Once the resource owner approves our request, we get the authorization code in response.

  • https://graph.facebook.com/v15.0/oauth/access_token is then used to exchange the authorization code with an access token. ... ...