Last active
December 24, 2017 16:53
-
-
Save marcorei/32a31862e1f0b862215253aee6eaa9e1 to your computer and use it in GitHub Desktop.
Check if you can access Firebase data with anonymous auth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fbScripTag = document.createElement('script'); | |
fbScripTag.setAttribute('src','https://www.gstatic.com/firebasejs/4.8.1/firebase.js'); | |
document.head.appendChild(fbScripTag); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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