Home > Uncategorized > Generate a #Facebook #AccessToken that never expires

Generate a #Facebook #AccessToken that never expires


I thought this was a very useful step by step guide to generating an access token in Facebook that never expires:

Steps for Creating Never Expire Page Access Token.

  1. Go To link https://developers.facebook.com/
  2. Login with your facebook Credential
  3. Go to Right upper Menu My Apps Select Add New App / Create New App
  4. After Creating a New App you have redirect to App Dashboard page
  5. Click on Dashboard you see App Id and App Secret
  6. Now You Go to App Review from the left menu. Make App Public.
  7. Now you go to Tools and Support menu
  8. Select Graph API Explorer
  9. Now at Right Upper Corner. Select Your Application. By default, “Graph Api Explorer” selected
  1. Now Click on Get Token Button. And then you see three option.
  2. Select “Get User Access Token” Popup open, Select  manage_pages and publish_pages Checkboxes and click on “Get Access Token” Button.
  3. Now Again Click on Get Token Button Select Page Access Token choose your Page.
  4. After Selecting your page your short term Access token is generated. That is in the Access token textbox.
  1. Now Click Information button(blue i button) that is in left side near the Access Token label. One poupu open, now click on “Open in Access Token tool”
  1. Another tab is open. Now Click on Extend Access Token. Two month Access Token is generated
  1. Now go to previous tab Graph Api Explorer paste this extended token in the Access token toolbox.
  2. Add one parameter in “access_token” in the get toolbox so final string looks like “me?fields=id,name, access_token”
  3. Click on submit button. Your never expire token is generated in the response
  4. Copy this and check this access token paste on Access Token debugger.

And to finish off, here’s a code example in C# to post to a Facebook business page:

static async Task PostToFacebookAsync(string accessToken, string pageId)
// Use HttpClient
using (var client = new HttpClient())
// Set variable values for post to facebook
string uri = string.Format(“https://graph.facebook.com/{0}/feed?”,pageId);
var strName = HttpUtility.UrlEncode(result.Title + suffix);
var strLink = HttpUtility.UrlEncode(result.MediaUrl);
// Formulate querystring for graph post
StringContent queryString = new StringContent(“access_token=” + accessToken + “&message=Hello+World”);

// Post to facebook /{page-id}/feed edge
HttpResponseMessage response = await client.PostAsync(new Uri(uri), queryString);
if (response.IsSuccessStatusCode)
// Get the URI of the created resource.
string postId = await response.Content.ReadAsStringAsync();
Console.WriteLine(“Post Successfully: Your Post ID is: {0}”,postId);

Console.WriteLine(“Something Went Wrong”);



Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: