I am using Firebase to allow the user to login to a Unity game via Facebook. It is working fine, but I cannot get access to the user's email by using this parameter auth.CurrentUser.Email. Also, the email is not stored in Firebase Authentication Console. The email can be stored/accessed succussfully when I use other sign-in methods, such as email and google.
Here is my code:
public void SignInFacebook()
{
var perms = new List<string>() { "public_profile", "email", "user_friends" };
FB.LogInWithReadPermissions(perms, AuthCallback);
}
private void AuthCallback(ILoginResult result)
{
if (FB.IsLoggedIn)
{
// AccessToken class will have session details
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
// Print current access token's User ID
Debug.Log(aToken.UserId);
// Print current access token's granted permissions
foreach (string perm in aToken.Permissions)
{
Debug.Log(perm);
}
Credential credential = FacebookAuthProvider.GetCredential(aToken.TokenString);
auth.SignInWithCredentialAsync(credential).ContinueWithOnMainThread(task => {
if (task.IsCanceled)
{
Debug.LogError("SignInWithCredentialAsync was canceled.");
return;
}
if (task.IsFaulted)
{
Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
return;
}
Firebase.Auth.FirebaseUser newUser = task.Result;
Debug.LogFormat("User signed in successfully: {0} - {2} - ({1})",
newUser.DisplayName, newUser.UserId, newUser.Email);
});
}
else
{
Debug.Log("User cancelled login");
}
}
And this is what it looks like in the console ("-" is where the email is supposed to be stored. If I use another sign-in method, such as email or google, the email is stored without any issues)
Similar questions were asked about this issue and it was suggested that I change the Account email address setting in Firebase to Prevent creation of multiple accounts with the same email address, but it did not solve the issue.
Thanks!

