It is possible with the admin SDK
The admin SDK cannot be used on the client, only in the Firebase cloud functions, which can then be called from the client. You will be given the following promises: (Itβs very easy to configure the cloud function .)
admin.auth().getUser(uid) admin.auth().getUserByEmail(email) admin.auth().getUserByPhoneNumber(phoneNumber)
look here https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data
In short, this is what you are looking for
admin.auth().getUser(data.uid) .then(userRecord => resolve(userRecord.toJSON().email)) .catch(error => reject({status: 'error', code: 500, error}))
full fragment
In the code below, I first check that the user calling this function has the right to display such confidential information about someone by checking if his uid is under the userRights/admin
node.
export const getUser = functions.https.onCall((data, context) => { if (!context.auth) return {status: 'error', code: 401, message: 'Not signed in'} return new Promise((resolve, reject) => {
By the way, read about the difference between onCall()
and onRequest()
here .
source share