var jwtClient = new google.auth.JWT(key.client_email, null, key.private_key, ["https://www.googleapis.com/auth/firebase.database", "https://www.googleapis.com/auth/userinfo.email"], null);
jwtClient.authorize(function(error, tokens) {
if (tokens) {
var es = new EventSource(url + "?access_token=" + tokens);
...
}
}
}var token = firebase.auth().createCustomToken("my-uid");
var es = new EventSource(url + "?access_token=" + token);
... var key = require('./' + process.env.SERVICEACCOUNTFILE);
var payload = {
"uid" : "my-uid",
"iat" : Math.floor(Date.now() / 1000),
"exp" : Math.floor(Date.now() / 1000 + 3600),
"iss" : key.client_email,
"sub" : key.client_email,
"aud" : "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
};
var token = jwt.sign(payload, key.private_key,
{
algorithm: 'RS256'
}
);Hi Joon,
This isn't my specialty, but have you tried printing out the URL you’re passing into EventSource? I suspect it’s not formatted quite how you expect here.
Michael Bleigh has an excellent example of REST auth using custom tokens here. I see that he uses tokens.access_token, where you’re directly trying to include tokens in your URL, which doesn’t seem quite right.
Note that he also passes the auth token as part of the headers, at the Authorization: Bearer... line. I’m not positive that what you have here wouldn’t work, but it does look a bit different than the recommended practice.
Again, I'm not very experienced here, but maybe those are good starting points for troubleshooting?
☼, Kato
--
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-talk+unsubscribe@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/4c458de6-364d-41a3-95dd-0a29045b8625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
var payload = {
"uid" : "my-uid",
"iat" : Math.floor(Date.now() / 1000),
"exp" : Math.floor(Date.now() / 1000 + 3600),
"iss" : key.client_email,
"sub" : key.client_email,
"aud" : "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
};
var token = jwt.sign(payload, key.private_key,
{
algorithm: 'RS256'
}
);
console.log(token);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/4c458de6-364d-41a3-95dd-0a29045b8625%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The Database REST API will accept access_token=<TOKEN> on the query string or header Authenticate: Bearer <TOKEN> to authenticate a request with a service account.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/dfc35789-c3cd-4086-a4ea-e91454edd674%40googlegroups.com.