简体   繁体   English

来自Google Cloud Endpoint的Firebase身份验证

[英]Firebase authentication from Google Cloud Endpoint

I have an Android app that uses Firebase with user authentication. 我有一个使用Firebase和用户身份验证的Android应用。 The authentication process is done via Facebook, Google or Twitter accounts and stores user data into Firebase. 身份验证过程通过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. 另一方面,我在App Engine中运行了Java中的Google Cloud Endpoint,该端点连接到Firebase以检索一些数据,并最终通过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. Firebase存储用户的GCM令牌,如果某些GCM令牌无效或已更新,则端点将连接到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令牌,而我正在考虑在Endpoint中实施身份验证过程,该过程会生成自定义令牌,仅允许端点写入用户节点。

Is this the way to go? 这是要走的路吗? or I'm totally wrong? 还是我完全错了?

If you want your Cloud Endpoint to authenticate with Firebase as "itself", you can mint a custom token and pass that into authWithCustomToken . 如果您希望Cloud Endpoint向Firebase以“自身”身份进行身份验证,则可以创建自定义令牌并将其传递给authWithCustomToken See this page in the docs: https://www.firebase.com/docs/android/guide/login/custom.html 请在文档中查看此页面: 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所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM