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

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

问题描述

我希望能够获取在 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) => { ... }

我需要获取发出请求的登录用户的 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 令牌并解码/在你的函数中验证它,或者你可以使用一个callableHTTPS功能,自动传递用户信息.

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天全站免登陆