It is important to make an independent call from the server, especially if you save your facebook user ID in a database or something like that. So you know if this is true.
First, after calling the FB.init function in the Facebook Javascript SDK, you want to get the user access token and facebook user ID through the Javascript SDK, like this:
FB.getLoginStatus(function (response) { if (response.status === 'connected') { var token = response.authResponse.accessToken; var facebookUserID = response.authResponse.userID; } });
Secondly, after you have received the user id and facebook user, you will want to transfer these variables to your server. If you use WCF or some other web service with JSON.NET , you can create a method such as:
[WebInvokeAttribute(BodyStyle = WebMessageBodyStyle.WrappedRequest, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] [OperationContractAttribute] public Stream AuthenticateFacebook(string facebookUserId, string token) { var json = new WebClient().DownloadString(string.Format("https://graph.facebook.com/me?access_token={0}", token)); JObject parsedJson = JObject.Parse(json);
You have now confirmed that the user is who they say.
source share