Using the new OAuthWebSecurity for authenticating with Facebook, I added the email permission on my Facebook application. Now, as I can read, I need to define a scope to be
I used Varun's answer, but I had to make a small modification to get it to work for my app being hosted on AppHarbor.
AppHarbor has to do some funky stuff with the port number in urls to handle load balancing. You can read a little more about it here. In short, getting the AbsoluteUri of the current request while hosting on AppHarbor may return a uri with a port number other than 80. This causes problems with Facebook authentication, because they expect your return url to be the one you specified when creating your app.
The problem comes in at string rawUrl = context.Request.Url.OriginalString; in VerifyAuthentication(). If you use this code, rawUrl may contain some port number other than 80, causing the Facebook authentication to fail. Instead, replace that line with
string rawUrl = GetRawUrl(context.Request.Url);
and add the GetRawUrl() function to the class:
public static string GetRawUrl(Uri url)
{
var port = url.Port;
if (SettingsHelper.GetHostingService() == HostingServices.AppHarbor)
port = 80;
return new UriBuilder(url)
{
Port = port
}.Uri.AbsoluteUri;
}
You will need to replace if (SettingsHelper.GetHostingService() == HostingServices.AppHarbor) with your own logic for determining whether or not your application is running on AppHarbor.