FirebaseExtended/firechat

Get permission_denied

daksamedia opened this issue · 1 comments

Hi everyone!

I tried the example by using anonymous user on this git.
I works flawless.
But when I changed it into my database & auth key, it did not work.

Here's the code
`

<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>

<!-- Firechat -->
<link rel="stylesheet" href="https://cdn.firebase.com/libs/firechat/3.0.1/firechat.min.css" />
<script src="https://cdn.firebase.com/libs/firechat/3.0.1/firechat.min.js"></script>

<!-- Custom CSS -->
<style>
  #firechat-wrapper {
    height: 475px;
    max-width: 325px;
    padding: 10px;
    border: 1px solid #ccc;
    background-color: #fff;
    margin: 50px auto;
    text-align: center;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    -webkit-box-shadow: 0 5px 25px #666;
    -moz-box-shadow: 0 5px 25px #666;
    box-shadow: 0 5px 25px #666;
  }
</style>
<script type="text/javascript"> // Initialize Firebase SDK var config = { apiKey: "xxx" //I blurred it, authDomain: "gelaro-dev.firebaseapp.com", databaseURL: "https://gelaro-dev.firebaseio.com", };
  firebase.initializeApp(config);

  // Get a reference to the Firebase Realtime Database
  var chatRef = firebase.database().ref();

  // Create an instance of Firechat
  var chat = new FirechatUI(chatRef, document.getElementById("firechat-wrapper"));

  // Listen for authentication state changes
  firebase.auth().onAuthStateChanged(function(user) {
    if (user) {
      // If the user is logged in, set them as the Firechat user
      chat.setUser(user.uid, "Anonymous" + user.uid.substr(10, 8));
    } else {
      // If the user is not logged in, sign them in anonymously
      firebase.auth().signInAnonymously().catch(function(error) {
        console.log("Error signing user in anonymously:", error);
      });
    }
  });
</script>
`

How could I make this work?
Is there any database configuration to figure it out?
Which part did I miss?

Thanks in advance,

Best Regards

I forgot to set these 2 things :

#1 Set rules on database
{ read:true, write:true }

#2 Enable Sign In Anonymous in Authentication