Get permanent access or offline access token of facebook using c#

Hi,

Are you looking for offline access token of Facebook using c#?

Please follow the steps as follows :

[Ignore this step if you have created application in Facebook and done with login  functionality]
Step 1: Create application into Facebook, Login using javascript and get the access token :
http://narendrajarad.blogspot.in/2014/07/facebook-login-using-javascript.html

[Ignore this step if you have already added reference of Facebook from NuGet packages to your project]
Step 2: Add a reference to Facebook to your project :
http://narendrajarad.blogspot.in/2014/07/add-reference-of-facebook-from-nuget-to.html

Finally, use this below code to "Get permanent access or offline access token of Facebook using c#".

 var client = new FacebookClient(hdfAccessToken.Value);
                //get permanent access token
                dynamic result = client.Post("oauth/access_token", new
                {
                    client_id = "Your Api Key",
                    client_secret = "Your Api Secret",
                    grant_type = "fb_exchange_token",
                    fb_exchange_token = hdfAccessToken.Value
                });
 //permanent access token is used when user is register with Facebook to your  application & you have to communicate with Facebook.
//this perment access token is also expires if Facebook user have changed the Facebook password.
//  Response.Write("OFFLINE ACCESS TOKEN: " + result.access_token + " <br/></br></br> ");
       
var offlineAccessToken = result.access_token;

Comments