I am trying to setup firebase server using nodejs as discussed Here. I have followed every steps from creating a project and downloading the .json file to changing the rules of the database but it still doesn't seem to work.
My code is not able to read or write data from/to any tables using admin privileges even the ones with public read and write access. This is my code from the server side:
var firebase = require('firebase');
firebase.database.enableLogging(true);
firebase.initializeApp({
serviceAccount: "./App.json",
databaseURL: "https://----.firebaseio.com"
});
//
var db = firebase.database();
var ref = db.ref("testPosts");
ref.once("value", function(snapshot){
console.log(snapshot.val());
}, function(error){
console.log(error);
});The code below is how the security is set on the server:
"rules": {
"users": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
},
"testPosts": {
".read": "auth != null",
".write": "auth != null"
}
}When I run the code I get the following error:
p:0: Listen called for /posts default
p:0: Making a connection attempt
p:0: Failed to get token: Error: Error refreshing access token: invalid_grant (Invalid JWT: Token must be a short-lived token and in a reasonable timeframe)
p:0: data client disconnected
p:0: Trying to reconnect in 77.64995932509191ms
0: onDisconnectEventsCan someone please help me with this? I have been struggling with it for a while now.
--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/677bdbb0-8809-4fe1-a502-77feef402d52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.