First you can get the current signed-in user tokenId by calling getIdToken()
on the User: https://firebase.google.com/docs/reference/js/firebase.User#getIdToken
firebase.auth().currentUser.getIdToken(true)
.then(function (token) {
// You got the user token
})
.catch(function (err) {
console.error(err);
});
Then send it to your cloud function.
Then in your cloud function you can use: https://firebase.google.com/docs/auth/admin/verify-id-tokens
Example:
admin.auth().verifyIdToken(idToken)
.then(function(decodedToken) {
var uid = decodedToken.uid;
// ...
}).catch(function(error) {
// Handle error
});
The documentation for decodedToken is here: https://firebase.google.com/docs/reference/admin/node/admin.auth.DecodedIdToken#uid
DecodedIdToken contains the user uid, then you can get the user by calling this: https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#getUser
Which returns a UserRecord https://firebase.google.com/docs/reference/admin/node/admin.auth.UserRecord