public ActionResult PostAuthorize(FacebookAuthenticationResult far)
        {
            if (far.IsSuccess)
            {
                var fb   = new Facebook(far.AccessToken); // Use that access token to get the facebook user id
                var user = fb.Get <User>("/me", new Dictionary <string, string> {
                    { "fields", "id" }
                });

                // then save the access token
                FacebookMembershipProvider.LinkFacebook(User.Identity.Name, user.ID, far.AccessToken, far.ExpiresIn);

                // You may want to actually redirect instead for just returning view.
                // so that the users dont's see the ugly and confusing url like this one
                // http://localhost:30326/Facebook/PostAuthorize?code=8b2055447e53702722917_doMoY.
                // for simplicity i will just return a view.
                return(View("LinkSuccess"));
            }

            return(View("LinkError", far));
        }
 public ActionResult Unlink()
 {
     FacebookMembershipProvider.UnlinkFacebook(User.Identity.Name);
     return(RedirectToAction("Index"));
 }