Firebase Database Permission denied with read/write permissions set to true

前端 未结 6 1768
予麋鹿
予麋鹿 2020-12-01 18:11

I\'m having trouble writing to my Firebase database in my simple Android app. I\'ve set my database rules to be public:

{
  \"rules\": {
    \".read\": true,         


        
相关标签:
6条回答
  • 2020-12-01 18:13

    I've been changing firestore rules instead of DB... Hope it helps to someone dumb like me.

    0 讨论(0)
  • 2020-12-01 18:14

    This looks like problem with your google-services.json.

    Make sure app name and client id are same as in firebase console.

    If you are not sure re-download google-services.json from your project's console and add it your project.

    0 讨论(0)
  • 2020-12-01 18:15

    I'm not entirely sure what the problem was, but I just deleted my project from Firebase and recreated it, deleting and installing the new google-services.json and it worked perfectly the second time.

    Luckily this is a test app and my database was empty, but if you're in this situation and have valuable information stored in your account, I would recommend exporting it before trying this solution.

    0 讨论(0)
  • 2020-12-01 18:17

    Complete Solution:

    1). Firstly go to Authentication Tab and select SIGN-IN-METHOD turn Anonymous On

    2). Secondly go to Database Tab and write Rule

    {
    "rules": {
    ".read": true,
    ".write": true
    }}
    

    3). Thirdly go to Storage Tab and write following rule

    service firebase.storage {
     match /b/myapplicationname-f2266.appspot.com/o {
     match /{allPaths=**} {
     allow read, write;
    }}}
    

    Note This solution is only for testing purpose with following steps you are giving public permission for Read and Write your database.

    0 讨论(0)
  • 2020-12-01 18:24

    Okay I have tried all above solution and failed. After a while I found that my Project has 2 modules and I call firebase in the second module instead of the main one, so the solution is to add the second one to the firebase project too, and it works.

    0 讨论(0)
  • 2020-12-01 18:26

    Maybe you should set your rules to: (I had the same problem. It works for me.)

    // These rules require authentication
        {
          "rules": {
            ".read": "auth != null",
            ".write": "auth != null"
          }
        }
    
    0 讨论(0)
提交回复
热议问题