Post examples of authentication and extended permissions

Sep 8, 2010 at 3:35 AM

Hi, I am trying to extend my application to allow facebook users to login via their facebook username.  My application is written in C# .Net.  I would like to use the Login to Facebook button on my site and make a call out to facebook to get the authorization code in order to make updates on the users behalf (in the code behind, not javascript).  I want to be able to send email or post a status update when they perform a function in my web application (after I get their permission).

Can you post some examples of how I might use the FaceSharp API in order to get an access code that would authorize my application to post to the user's wall via their status or get their email address?



Sep 8, 2010 at 4:04 AM
Edited Sep 8, 2010 at 4:07 AM


FaceSharp currently has both a Facebook App and a website incorporating Facebook Login.

In particular you will want to look at Facebook.MVC --> Controllers --> DefaultController.cs

The attribute FacebookGraphApiFilter allows you to determine if a user has granted access to your application (which would allow you to get their email address and post to their wall)


        [FacebookGraphApiFilter(ForceLogin = false)]
        public ActionResult Index()
            // Is the user logged in?
            if (HttpContext.Items["uid"] != null)
                // Get user's information (possibly including email)
                ViewData["user"] = new FacebookApi().User.GetCurrentUser();

            var applicationId = ConfigurationManager.AppSettings["ApplicationId"];
            ViewData["ApplicationId"] = applicationId;
            return View();

You can view this in action at

I hope that this helps.


Sep 8, 2010 at 6:57 PM

hi Patrick, thank you for this great kit. i just downloaded the 1.03b.

I have a problem, on the request for user's permission, only the Access my basic information and Send me email are the ones coming up. THe other extended permissions although in web.config don't seem to be picked up. any idea why?

Also in the current application setup in FB, there is no more Post-Authorize Callback/Redirect URL, in contrary to the setup procedure document you have here.


Sep 8, 2010 at 11:37 PM
Ermi, I'll look into your issues later tonight and post the results back here. -Patrick
Sep 9, 2010 at 3:03 AM


Thanks for pointing out the Post-Authorize Callback/Redirect URL discrepancy in the documentation, for existing applications the two options remain; the options are no longer available to newly created applications

The code will have to be updated to accommodate this platform change, expect a change soon to resolve your issues.

Thank you very much for pointing this out.


Sep 9, 2010 at 1:40 PM


The code has been updated to resolve the issue with Post-Authorize URL as well as the request for user's permissions.

Thanks again for identifying these issues!