How to access the users Email id with mvc facebook?

I am using this Link as a starting point as i am new to MVC as such.

I have been able to get the data of the facebook users what permissions should i use to get the users Email ID and where?

dynamic me = client.Get("me");
if (response.ContainsKey("verified"))
    facebookVerified = response["verified"];
    facebookVerified = false;
db.ExternalUsers.Add(new ExternalUserInformation
     UserId = newUser.UserId,
     FullName =,
     Link =,
     Email = model.Email, // Want the Email ID from Facebook
     Gender = me.gender,
     Verified = facebookVerified


public ActionResult Login(LoginModel model, string returnUrl)
    if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
        return RedirectToLocal(returnUrl);

    // If we got this far, something failed, redisplay form
    ModelState.AddModelError("", "The user name or password provided is incorrect.");
    return View(model);


What you are missing here is getting additional permission for getting the email address from facebook.

See the below two screenshot, second screenshot requests for additional information including email.

Basic Permission

More Permissions

To do that you need to this additional required info as "scope".

I did a little tutorial on how to login with facebook today and can be read here - Using Facebook Login with ASP.NET MVC 4. This will answer most of your queries.

For your question here is what you should do:

Create a FacebookScopedClient class (code below) and then in your AuthConfig.cs use it like this

var facebooksocialData = new Dictionary<string, object>();
facebooksocialData.Add("scope", "email, publish_stream, read_stream");

OAuthWebSecurity.RegisterClient(new FacebookScopedClient(
    appId: "xxxxxxxx",
    appSecret: "xxxxxxxxxxxxxxxxxxx",
    scope:"email, user_likes, friends_likes, user_birthday),

Code for FacebookScopedClient class -

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using DotNetOpenAuth.AspNet;
using Newtonsoft.Json;

public class FacebookScopedClient : IAuthenticationClient
    private string appId;
    private string appSecret;
    private string scope;

    private const string baseUrl = "";
    public const string graphApiToken = "";
    public const string graphApiMe = "";

    private static string GetHTML(string URL)
        string connectionString = URL;

            System.Net.HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(connectionString);
            myRequest.Credentials = CredentialCache.DefaultCredentials;
            //// Get the response
            WebResponse webResponse = myRequest.GetResponse();
            Stream respStream = webResponse.GetResponseStream();
            StreamReader ioStream = new StreamReader(respStream);
            string pageContent = ioStream.ReadToEnd();
            //// Close streams
            return pageContent;
        catch (Exception)
        return null;

    private IDictionary<string, string> GetUserData(string accessCode, string redirectURI)
        string token = GetHTML(graphApiToken + "client_id=" + appId + "&redirect_uri=" + HttpUtility.UrlEncode(redirectURI) + "&client_secret=" + appSecret + "&code=" + accessCode);
        if (token == null || token == "")
            return null;
        string access_token = token.Substring(token.IndexOf("access_token="), token.IndexOf("&"));
        string data = GetHTML(graphApiMe + "fields=id,name,email,username,gender,link&" + access_token);

        // this dictionary must contains
        Dictionary<string, string> userData = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
        return userData;

    public FacebookScopedClient(string appId, string appSecret, string scope)
        this.appId = appId;
        this.appSecret = appSecret;
        this.scope = scope;

    public string ProviderName
        get { return "Facebook"; }

    public void RequestAuthentication(System.Web.HttpContextBase context, Uri returnUrl)
        string url = baseUrl + appId + "&redirect_uri=" + HttpUtility.UrlEncode(returnUrl.ToString()) + "&scope=" + scope;

    public AuthenticationResult VerifyAuthentication(System.Web.HttpContextBase context)
        string code = context.Request.QueryString["code"];

        string rawUrl = context.Request.Url.OriginalString;
        //From this we need to remove code portion
        rawUrl = Regex.Replace(rawUrl, "&code=[^&]*", "");

        IDictionary<string, string> userData = GetUserData(code, rawUrl);

        if (userData == null)
            return new AuthenticationResult(false, ProviderName, null, null, null);

        string id = userData["id"];
        string username = userData["username"];

        AuthenticationResult result = new AuthenticationResult(true, ProviderName, id, username, userData);
        return result;


Need Your Help

Why my pageviews count on Google Analytics vs Adwords doesn't fit?

javascript google-analytics google-analytics-api google-adwords

Since the beginning of my Adwords campaign, every visit are perfectly calculated in my Google Analytics account. However, if I look up my Adwords visitor clicks (~1250) and my GA inbound visits (~2...