访问 userID 的 Firebase HTTP 函数?

Firebase HTTP function accessing userID?

几个关于 firebase 函数的问题。

我有一个功能需要验证当前用户是否已通过身份验证,然后使用他们的 userId 存储一些数据并将其关联到他们。

首先,请查看官方 sample code available in GitHub that shows how to protect an endpoint. You'll see that it takes a token from Firebase Authentication for the currently authenticated user using getIdTokenWithCompletion. The function uses the Firebase Admin SDK to verify the token. The result of verification is a DecodedIdToken 对象,其中包含各种属性,包括用户的 uid。