从请求到Firebase中的Cloud Function获取用户信息 [英] Getting user info from request to Cloud Function in Firebase

查看:117
本文介绍了从请求到Firebase中的Cloud Function获取用户信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够获取在Firebase中被调用的Cloud Function的用户信息.我有类似这样的内容,在用户登录应用后被调用:

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) => { ... }

我需要获取发出请求的登录用户的uid.有任何建议或意见吗?

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

推荐答案

关于发出请求的用户的信息不会与HTTPS函数调用一起自动传递.

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

您可以随身携带ID令牌并解码/在您的函数中进行验证,或者您可以使用可调用 HTTPS功能,该功能会自动传递用户信息.

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.

这篇关于从请求到Firebase中的Cloud Function获取用户信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆