且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过 HTTP REST API 访问我的 Firebase 数据库?

更新时间:2022-11-27 13:45:29

所以在和技术支持沟通之后,我的答案是:

So after communicating with technical support, here's my answer:

在您的数据库规则中,包含与您正在执行的操作兼容的类似内容:

In your database rules, include something like this that is compatible with what you're doing:

{
"rules": {
"users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id === auth.uid",
".read": "$user_id === auth.uid"
}
    }
  } 
}

在您的数据库中,创建一个 users 表,并在其中创建一个表,其中包含您的 身份验证电子邮件/您正在使用的密码帐户.在该表中是您可以通过 access-key 访问的信息.

And in your database, create a users table, and within that, create a table with the name of your <user-id> of the authentication email/password account you are using. Within that table is the information you will be able to access via your access-key.

然后发送这样的请求:

https://samplechat.firebaseio-demo.com/users/<user-id>.json?auth=<access-key>

其中 access-key 是可以称为 idTokenid_Tokenaccess_key 的密钥来自 Google 的 JSON 响应.

Where access-key is the key that can be known as idToken, id_Token, or access_key in JSON responses from Google.