title: Unity, Firebase Auth, CurrentUser.ProviderData IUserInfo For Provider facebook.com Has Email Property Blank
body: <p>I'm fairly new to firebase but I am trying to set up a facebook login for my app. I have succeeded in following tutorials to log in to facebook and have finally managed to put together the handover of access token to firebase for a firebase account. I experimented with making changes to my facebook account to see if they were mirrored on the firebase account and of course they weren't. I discovered ProviderData and found that on my Android device I had two entries from two providers, firebase and facebook.com . I mocked up a display of the data I was after (name, email, photourl) for the two and noticed that the email in the facebook data was blank.</p>
  
  <p>Hours of googling later and I still don't have a clue. The most common answer for similar problems is:</p>
  
  <ul>
  <li>Make sure you've requested the "email" permission. TICK</li>
  <li>Make sure you project is set to "one account per email address" in the firebase console. TICK</li>
  </ul>
  
  <p>I've checked and double checked both of those every time I read them on yet another thread about a problem similar to this. When I change my settings on facebook they're not updated in firebase (duh). I need to get the updated data from somewhere and it seems ProviderData is that place. Email isn't being included in the provider data for facebook?</p>
  
  <p>Here's my code. Most of it is for updating text in my UI so I can do some debugging without having to get the console working.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  using Facebook.Unity;
  
  
  public class FBscript : MonoBehaviour {
      public GameObject DialogLoggedIn;
      public GameObject DialogLoggedOut;
      public GameObject DialogUsername;
      public Image DialogProfilePic;
      Firebase.Auth.FirebaseAuth auth;
      Firebase.Auth.FirebaseUser user;
  
      public List&lt;Text&gt; displayNameText;
      public List&lt;Text&gt; emailText;
      public List&lt;Text&gt; photoURLText;
      public List&lt;Text&gt; userIDText;
      public List&lt;Text&gt; providerText;
      public Text testText;
      public List&lt;Text&gt; permissionsText;
  
  
      private void Awake() {
          auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
          FB.Init(SetInit, OnHideUnity);
      }
  
      void SetInit() {
          if (FB.IsLoggedIn) {
              Debug.Log("FB is logged in");
          } else {
              Debug.Log("FB is not logged in");
          }
          DealWithFBMenus(FB.IsLoggedIn);
      }
  
      void OnHideUnity(bool isGameShown) {
          if (!isGameShown) {
              Time.timeScale = 0;
          } else {
              Time.timeScale = 1;
          }
      }
  
      public void Logout() {
          if (FB.IsLoggedIn) {
              FB.LogOut();
          }
          if (user != null) {
              auth.SignOut();
          }
          DealWithFBMenus(FB.IsLoggedIn);
      }
  
      public void FBlogin() {
          List&lt;string&gt; permissions = new List&lt;string&gt;();
          permissions.Add("public_profile");
          permissions.Add("email");
  
          FB.LogInWithReadPermissions(permissions, AuthCallBack);
      }
  
      void AuthCallBack(IResult result) {
          if (result.Error != null) {
              Debug.Log(result.Error);
          } else {
              if (FB.IsLoggedIn) {
                  Debug.Log("FB is logged in");
              } else {
                  Debug.Log("FB is not logged in");
              }
              DealWithFBMenus(FB.IsLoggedIn);
          }
      }
  
      void DealWithFBMenus(bool isLoggedIn) {
          DialogLoggedIn.SetActive(isLoggedIn);
          DialogLoggedOut.SetActive(!isLoggedIn);
          if (isLoggedIn) {
              FirebaseLogin();
              //This is testing to make sure the email has sufficient permissions to be sent
              FB.API("/me?fields=email", HttpMethod.GET, DisplayUsername);
              //FB.API("/me?fields=first_name", HttpMethod.GET, DisplayUsername);
              //FB.API("/me/picture?type=square&amp;height=128&amp;width=128", HttpMethod.GET, DisplayProfilePic);
          }
      }
  
      void DisplayUsername(IResult result) {
          Text Username = DialogUsername.GetComponent&lt;Text&gt;();
  
          if (result.Error == null) {
              //Username.text = "Hi there, " + result.ResultDictionary["first_name"];
              Username.text = result.ResultDictionary["email"].ToString();
          } else {
              Debug.Log(result.Error);
          }
      }
  
      /*
      void DisplayProfilePic(IGraphResult result) {
          if (result.Texture != null) {
              Image ProfilePic = DialogProfilePic.GetComponent&lt;Image&gt;();
              ProfilePic.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2());
          }
      }
      */
  
      void FirebaseLogin() {
  
          ///ON SCREEN DEBUGGING
          foreach (Text permissionText in permissionsText) {
              permissionText.text = "";
          }
          int z = 0;
          foreach (string permission in AccessToken.CurrentAccessToken.Permissions) {
              permissionsText[z].text = permission;
              z += 1;
          }
          ///
          ///
          ///
  
  
  
          Firebase.Auth.Credential credential = Firebase.Auth.FacebookAuthProvider.GetCredential(AccessToken.CurrentAccessToken.TokenString);
          auth.SignInWithCredentialAsync(credential).ContinueWith(task =&gt; {
              if (task.IsCanceled) {
                  Debug.LogError("SignInWithCredentialAsync was canceled.");
                  return;
              }
              if (task.IsFaulted) {
                  Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                  return;
              }
  
              Firebase.Auth.FirebaseUser user = task.Result;
              Debug.LogFormat("User signed in successfully: {0} ({1})",
                  user.DisplayName, user.UserId);
  
              //
              //
              //THIS IS ALL PURELY ON SCREEN DEBUGGING.
              //
              //
              if (user != null) {
                  Debug.Log("a");
                  List&lt;Firebase.Auth.IUserInfo&gt; providerData = user.ProviderData as List&lt;Firebase.Auth.IUserInfo&gt;;
                  Debug.Log(providerData.Count);
                  Debug.Log(providerData[0].DisplayName);
                  displayNameText[0].text = providerData[0].DisplayName;
                  emailText[0].text = providerData[0].Email;
                  if (providerData[0].PhotoUrl != null) {
                      photoURLText[0].text = providerData[0].PhotoUrl.ToString();
                      StartCoroutine(SetupProfilePicture(providerData[0].PhotoUrl.ToString()));
                  } else {
                      photoURLText[0].text = "";
                  }
                  userIDText[0].text = providerData[0].UserId;
                  providerText[0].text = providerData[0].ProviderId;
  
                  int i = 0;
                  foreach (Firebase.Auth.IUserInfo profile in user.ProviderData) {
                      if (displayNameText.Count &gt;= i + 1) {
                          displayNameText[i].text = profile.DisplayName;
                          emailText[i].text = profile.Email;
                          if (profile.PhotoUrl != null) {
                              photoURLText[i].text = profile.PhotoUrl.ToString();
                          }
                          userIDText[i].text = profile.UserId;
                          providerText[i].text = profile.ProviderId;
                          i += 1;
                      }
                  }
                  testText.text = i.ToString();
              } else {
                  Debug.Log("b");
                  displayNameText[0].text = user.DisplayName;
                  emailText[0].text = user.Email;
                  if (user.PhotoUrl != null) {
                      photoURLText[0].text = user.PhotoUrl.ToString();
                      StartCoroutine(SetupProfilePicture(user.PhotoUrl.ToString()));
                  } else {
                      photoURLText[0].text = "";
                  }
                  userIDText[0].text = user.UserId;
              }
              ///
              ///
              ///
          });
      }
  
      IEnumerator SetupProfilePicture(string givenURL) {
          WWW www = new WWW(givenURL);
          yield return www;
          DialogProfilePic.sprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0));
      }
  }
  </code></pre>