Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate Facebook user token server side

I am having problem understanding how to implement a Facebook login workflow for my web app. I am stuck in the validation of the user token server side.

I am using C# SDK library. I am trying to validate the user token using the following code:

var fb = new FacebookClient();
    fb.AppId = "0000000000000";
    fb.AppSecret = "000000000000000000000";    

    dynamic result = fb.Get("debug_token", new { input_token = c_accessToken });

I get the following error when running the Get command.

OAuthException - #100) (#100) You must provide an app access token
or a user access token that is an owner or developer of the app

I changed the appId and appSecret for privacy reasons, but I double checked them and they are valid.

like image 1000
Idan Shechter Avatar asked Oct 23 '25 17:10

Idan Shechter


1 Answers

You need to send App Access Token That is the error you are getting. To get an App access token follow this documentation from facebook

https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens

To generate App Access Token you need to make a GET request from your FacebookClient() or using HttpClient()to this API endpoint.

GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials

this the documentation link for 'debug_token' endpoint https://developers.facebook.com/docs/facebook-login/access-tokens/debugging-and-error-handling

like image 73
Jawand Singh Avatar answered Oct 26 '25 07:10

Jawand Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!