Email is null in the "OnRegistered" event

I am trying to use the OnRegistered event to create a custom user.
After using Facebook to authentic the session.Email is always null. The weird thing is that the userAuth table has the email addtress. So it’s present when calling the base method but empty when I try to get the email.
When I call:

var user = session.ConvertTo<MyCustomUser>();

it never gets the email, despite the fact that the property is called “Email”. It seems like it should be populated. The value is definitely in the userAuth table but I can’t see to figure out where it comes from.
How can I get the email address during the “OnRegistered” event?

What is your “oauth.facebook.Fields” setting in web.config? And can you show a standalone sample how do you register user?

The Email field is used as a username login, check for the Email from OAuth Providers in PrimaryEmail property instead.

Also details gathered from each OAuth provider is maintained in session.ProviderOAuthAccess, which is where you’ll find which user info was received from Facebook.

Thanks. I will give that a try.

This worked for me:

       var props = session.ProviderOAuthAccess[0].Items;

        using (var db = authService.TryResolve<IDbConnectionFactory>().Open())
            user.Email = DecodeEncodedNonAsciiCharacters(props["email"]);
        public string DecodeEncodedNonAsciiCharacters(string value)
            return Regex.Replace(
               m => { return ((char)int.Parse(m.Groups["Value"].Value, 
1 Like