firebase-token-generator on parse cloudcode

141 views
Skip to first unread message

Evans Attafuah

unread,
Jul 6, 2015, 9:44:40 AM7/6/15
to fireba...@googlegroups.com
Hello,

Is there an easy way to generate firebase tokens using parse's cloudcode? 

Michael Lehenbauer

unread,
Jul 6, 2015, 11:44:50 AM7/6/15
to fireba...@googlegroups.com
Great question!  We have a JavaScript token generator, so it definitely seems like it should be possible but I'm not sure exactly what the limits of the parse runtime environment is.  You could try just copy/pasting the standalone JS version of our token generator into parse cloud code and see what happens: https://github.com/firebase/firebase-token-generator-node/blob/master/dist/firebase-token-generator.js  In theory, that should create a FirebaseTokenGenerator global that you can use as shown here.  If it doesn't work, let us know what you run into.  It should be possible to find a solution.

Good luck!
-Michael

On Mon, Jul 6, 2015 at 6:44 AM, Evans Attafuah <evans.a...@gmail.com> wrote:
Hello,

Is there an easy way to generate firebase tokens using parse's cloudcode? 

--
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/210d30ed-c04f-4175-9c44-f3da57defeb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evans Attafuah

unread,
Jul 7, 2015, 8:46:11 AM7/7/15
to fireba...@googlegroups.com
Hello Micheal,

Thanks for this. I looked at it earlier and saw some window declarations in the code so I  thought it was just for web browsers because cloud code doesn't have a window environment. 

But I will try implementation and let you know.

Thanks. 

You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/KlyhoUJ5MX4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Michael Lehenbauer

unread,
Jul 7, 2015, 12:17:47 PM7/7/15
to fireba...@googlegroups.com
Yeah, I'm honestly not sure if it'll work or not.  The raw source is here and isn't very complicated (a lot of the code is error validation and stuff).  We compile it for both node.js and the browser (as well as a "debug" version that's not minified, but it has a lot of extra code): https://github.com/firebase/firebase-token-generator-node/blob/master/dist/

I'm sure it's possible to get it working, but I'm not sure what the least painful route will be.  If you run into specific issues, let us know.  We may be able to help.

Good luck!
-Michael

Evans Attafuah

unread,
Jul 14, 2015, 6:42:10 PM7/14/15
to fireba...@googlegroups.com
Hello Micheal,

I tried it and got this error " TypeError: object is not a function" and am suspecting that the file is not being exported as a module like so exports.FirebaseTokenGenerator = FirebaseTokenGenerator;

can you help me resolve this?.

Evans Attafuah

unread,
Jul 14, 2015, 7:16:18 PM7/14/15
to fireba...@googlegroups.com
ok so I tried the node distribution and it works like magic. :)


I got back this,

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2IjowLCJkIjp7InVpZCI6ImN5ZmE6QVV3bHJDTk1rYyIsInNvbWUiOiJBVXdsckNOTWtjIiwiZGF0YSI6InNvbWUgZGF0YSJ9LCJpYXQiOjE0MzY5MTU0Mjd9.z5uAlret6HIjlzF9Ro5t-8KkQxky-Yeol9HsdrhT5RI

Thanks. 

Jacob Wenger

unread,
Jul 14, 2015, 7:25:12 PM7/14/15
to fireba...@googlegroups.com
Hi Evans,

I'm glad to hear it worked!

A word of warning: you should never, ever post authentication tokens in public forums like this. You should change your Firebase app's secret immediately to revoke the token you just posted.

Jacob

--
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.

GmailMe

unread,
Jul 15, 2015, 2:13:10 AM7/15/15
to fireba...@googlegroups.com
Hello Micheal,

I did that before posting. :)

Thanks for the tip. 

Sent from my iPhone 6
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/KlyhoUJ5MX4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages