来自Google Cloud Endpoint的Firebase身份验证

时间:2022-08-22 10:54:28

I have an Android app that uses Firebase with user authentication. The authentication process is done via Facebook, Google or Twitter accounts and stores user data into Firebase.

我有一个使用Firebase和用户身份验证的Android应用。身份验证过程通过Facebook,Google或Twitter帐户完成,并将用户数据存储到Firebase中。

In the other hand, I have a Google Cloud Endpoint in Java running in App Engine that connects to Firebase to retrieve some data and eventually sends a message to other users through Google Cloud Messaging. Firebase stores the users GCM tokens and if some of the GCM tokens are invalid or were updated, the Endpoint connects to Firebase to update those GCM tokens into the users node.

另一方面,我在App Engine中运行了一个Java Cloud Endpoint,它连接到Firebase以检索一些数据,并最终通过Google Cloud Messaging向其他用户发送消息。 Firebase会存储用户GCM令牌,如果某些GCM令牌无效或已更新,则Endpoint会连接到Firebase,以将这些GCM令牌更新到用户节点。

Right now, my users node security rules are as follows:

现在,我的用户节点安全规则如下:

"rules": {
"users": {
  ".read": "auth !== null",

  "$uid": {
    // grants write access to the owner of this user account whose uid must exactly match the key ($uid)
    ".write": "auth !== null && auth.uid === $uid" 

At the moment, the Google Cloud Endpoint is not allowed to update the users GCM Tokens and I'm thinking to implement an authentication process in the Endpoint that generates a custom token just to allow the endpoint to write into the users node.

目前,Google Cloud Endpoint不允许更新用户GCM令牌,而我正在考虑在端点中实施身份验证过程,该过程生成自定义令牌只是为了允许端点写入用户节点。

Is this the way to go? or I'm totally wrong?

这是要走的路吗?或者我完全错了?

1 个解决方案

#1


2  

If you want your Cloud Endpoint to authenticate with Firebase as "itself", you can mint a custom token and pass that into authWithCustomToken. See this page in the docs: https://www.firebase.com/docs/android/guide/login/custom.html

如果您希望Cloud Endpoint通过Firebase身份验证为“本身”,您可以创建自定义令牌并将其传递给authWithCustomToken。请参阅文档中的此页面:https://www.firebase.com/docs/android/guide/login/custom.html

The process is similar to what Jenny described for Node.js in How do you authenticate a server to Firebase?

这个过程类似于Jenny在如何向Firebase验证服务器的Node.js中所描述的过程?

#1


2  

If you want your Cloud Endpoint to authenticate with Firebase as "itself", you can mint a custom token and pass that into authWithCustomToken. See this page in the docs: https://www.firebase.com/docs/android/guide/login/custom.html

如果您希望Cloud Endpoint通过Firebase身份验证为“本身”,您可以创建自定义令牌并将其传递给authWithCustomToken。请参阅文档中的此页面:https://www.firebase.com/docs/android/guide/login/custom.html

The process is similar to what Jenny described for Node.js in How do you authenticate a server to Firebase?

这个过程类似于Jenny在如何向Firebase验证服务器的Node.js中所描述的过程?