问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/52444812/getting-user-info-from-request-to-cloud-function-in-firebase