Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting user info from request to Cloud Function in Firebase

I'd like to be able to get user information for a Cloud Function that gets called in Firebase. I have something like this, which is being called after the user signs into the app:

exports.myFunction = functions.https.onRequest((req, res) => { ... }

And I need to get the uid of the signed-in user that made the request. Any advice or comments please?

like image 772
user60786 Avatar asked Sep 21 '18 13:09

user60786


People also ask

Does Firebase use HTTP requests?

You can connect an HTTP function to Firebase Hosting. Requests on your Firebase Hosting site can be proxied to specific HTTP functions. This also allows you to use your own custom domain with an HTTP function. Learn more about connecting Cloud Functions to Firebase Hosting.


1 Answers

Information about the user that makes the request is not automatically passed along with HTTPS functions calls.

You can either pass the ID token along yourself and decode/verify it in your function, or you can use a callable HTTPS function, which passes the user information along automatically.

like image 83
Frank van Puffelen Avatar answered Nov 08 '22 02:11

Frank van Puffelen