Skip to content

Instantly share code, notes, and snippets.

@marcorei
Last active December 24, 2017 16:53
Show Gist options
  • Save marcorei/32a31862e1f0b862215253aee6eaa9e1 to your computer and use it in GitHub Desktop.
Save marcorei/32a31862e1f0b862215253aee6eaa9e1 to your computer and use it in GitHub Desktop.
Check if you can access Firebase data with anonymous auth
var fbScripTag = document.createElement('script');
fbScripTag.setAttribute('src','https://www.gstatic.com/firebasejs/4.8.1/firebase.js');
document.head.appendChild(fbScripTag);
var config = {
apiKey: "<API_KEY>",
authDomain: "<PROJECT_ID>.firebaseapp.com",
databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
storageBucket: "<BUCKET>.appspot.com",
messagingSenderId: "<SENDER_ID>",
};
firebase.initializeApp(config);
firebase.auth().signInAnonymously().catch(function(error) {console.log(error)})
var database = firebase.database();
database.ref("/").once("value").then(function(stuff) {console.log(stuff.val())});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment