Search code examples
facebook-graph-apiasp.net-mvc-4oauth-2.0facebook-oauth

MVC 4 oAuth With Facebook does not return email address


I am experimenting witht he MVC 4 oAuth that was released this month. Can anyone point me to where I can add eMail address so that I can store that with user properties?

I need to be able to send a welcome email but don't know where to start with the out of the box MVC 4 oAuth.

Ideally, after successful login, I want to receive the User Info from Facebook in my controller and drop it in a table so an offline process can send the welcome email.

Thanks, Victor


Solution

  • In order for Facebook to return an e-mail you must specify it in the scope. For example with the JS SDK you would do something like....

    return FB.login(function(response) {
        if (response.authResponse) {
          return window.location = '/auth/facebook/callback';
        }
      }, {scope: 'email,user_likes'}
    );