Marcos Anderson Marcos Anderson - 1 month ago 20
C# Question

Get access token to facebook page - WPF

I am developing a WPF application that needs post on wall of a facebook's Page, and this without login window.
Well, I want to get access token for my facebook page, and this is my code.

var fb = new FacebookClient();
string token = "";
dynamic accounts = fb.Get("/"<USER_ID>"/accounts");
foreach (dynamic account in accounts)
if ( == <PAGE_ID>)
token = account.access_token;

But I receive a error #104. It is a simple error, that I need a access token to do this operation.
Then I use other code to get the user access token

var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new
client_id = <PAGE_ID>,
client_secret = <APP_SECRET>,
grant_type = "fb_exchange_token",
fb_exchange_token = <USER_TOKEN>

But I get error #101:

"Error validating application. Cannot get application info due to a system error."

Someone knows what I have to do?



I'm not sure if you've been able to get a never expiring token for the page, so I'll explain you the steps:

  1. Open Graph API Explorer

  2. Select your app from the drop-down

    enter image description here

  3. Click "Get Access Token" button, and select the manage_pages permission.

  4. Copy the token and run this in the browser:{app-id}&client_secret={app-secret}&fb_exchange_token={step-3-token}
  5. Copy the token from step-4 and paste in to the access_token field and call:

  6. The token you get now is a never-expiring token, you can validate the same in Debugger .Use this in your app.

But beware, its not recommended to use this token on client side if your app is public.