0

(1) Question:

Is there a way to read user email having the uid? (permitted only for super user or server)

Ps.: I don't want to save in the Realtime database, because even though only the current user can change it, he can erase or put some fake email..

(2) Problem:

I'm trying to retrieve user email with GoogleAuthProvider in Firebase v3

Thats the code I'm using:

  signInWithGoogle(): Promise<any> {
    let provider = new firebase.auth.GoogleAuthProvider();
    provider.addScope("https://www.googleapis.com/auth/userinfo.email");
    return firebase.auth().signInWithPopup(provider)
            .then((result) => {
              console.log(result.user.email);
              console.log(result.credential);
              let token = result.credential.accessToken;
              return this.createOrUpdateUser(result.user, token);
            });
  }

The result:

result.user.email # null
result.user.providerData[0].email # correct_email@gmail.com

Firebase auth dashboard Even though the email is in the providerData, it is not attached to the auth.. Is it a firebase bug or can I fix it somehow?

Thanks!

felipepastorelima
  • 947
  • 1
  • 10
  • 23
  • I suggest you to take a look at this: http://stackoverflow.com/questions/38202055/accessing-email-address-in-firebase-rules – Devid Farinelli Jul 12 '16 at 13:40
  • There is no way to look up a user's email by their uid within the Firebase Authentication API. See [this recent answer](http://stackoverflow.com/questions/38168973/how-to-get-the-list-of-registered-user-in-firebase/38170753#38170753). Most devs store the user information in the database to allow listing/lookup. See the answer David linked. – Frank van Puffelen Jul 12 '16 at 14:51

1 Answers1

0

The 3.2.0 web sdk launched yesterday should automatically ask for the profile scope when signInWithPopup for google provider. Try deleting the test user and sign in again. The top level email should be populated.

bojeil
  • 29,642
  • 4
  • 69
  • 76