How do I access my Firebase Database via HTTP REST API?

后端 未结 1 1949
花落未央
花落未央 2020-12-23 10:45

Thanks to this answer I am able to connect to Firebase 3 via HTTP REST API and an email/password. Logging in with this API returns an access token that is used to access the

相关标签:
1条回答
  • 2020-12-23 11:17

    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"
    }
        }
      } 
    }
    

    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.

    Then send a request like this:

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

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

    0 讨论(0)
提交回复
热议问题