Hi now i am using firebase REST API
When i used public database rule
it's successful to set,update or delete data to database
/* database rule */
{
"rules": {
".read": true,
".write": true
}
}
/* Put data to database successful */
curl -X PUT -d '{
"alanisawesome": {
"name": "Alan Turing",
"birthday": "June 23, 1912"
}
}' 'https://mydatabe.firebaseio.com/users.json'
But i wanted to use auth REST, how can i get token? Here is my step.
First change database rule to
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}
Then i used Firebase SDK to login by google and get token
You can see i print token by "console.log(token);"
For example i got token is "AABBCCDD"
var provider = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider).then(function(result) {
var token = result.credential.accessToken;
var user = result.user;
console.log(token);
}).catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
var email = error.email;
var credential = error.credential;
});
I checked my Firebase console > Auth > User and there have my account
So that mean i successful to register my account to database
Second i used REST API like
curl -X PUT -d '{
"alanisawesome": {
"name": "Alan Turing",
"birthday": "June 23, 1912"
}
}' 'https://mydatabe.firebaseio.com/users.json?auth=AABBCCDD'
But it returned { "error" : "Could not parse auth token." }
So what is the problem? which step is worng?
Thanks