Is Firebase 3 available from a chrome extension?

639 views
Skip to first unread message

Takuji Shimokawa

unread,
Jun 7, 2016, 11:25:28 AM6/7/16
to Firebase Google Group
Hello.

I am trying to use Firebase from a chrome extension.
And I get an error as below.


Here is the sample application that causes the error.

I know there is an official sample application, but it's for older version of Firebase.

Does anyone know if Firebase 3 is available from a chrome extension?

Thanks.

boj...@google.com

unread,
Jun 7, 2016, 6:27:47 PM6/7/16
to Firebase Google Group
Currently Chrome Extensions are not supported. We will take your feedback into account and relay your request to the relevant parties.

Kato Richardson

unread,
Jun 7, 2016, 7:07:34 PM6/7/16
to Firebase Google Group
Hi Takuji,

Great to hear from you.

As Bassam mentioned, Chrome Extensions aren't something we test and certify against, but it seems like it should be possible to get some basic functionality going here--I've made a few that interact with Firebase over the years.

If you are willing to forge ahead into uncharted territory, I'd be happy to see what we can figure out.

If so, ping me off-list with the output from your networking tab (assuming you can get this in the extension, it can be tricky), and debug logging output by firebase.database.enableLogging(true);

You may or may not be able to turn on debug logging. I have a suspicion this is failing before initialization (which hopefully the networking output will help determine).

☼, 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-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/998edfce-aaac-411a-80e4-38b04f2d616f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Takuji Shimokawa

unread,
Jun 8, 2016, 11:50:55 PM6/8/16
to Firebase Google Group
Hi Bassam and Kato.

Thank you for your quick responses.

OK, then I'll take a different way.
Unfortunately I don't have time to investigate this incident.

Thanks again.

2016年6月8日水曜日 8時07分34秒 UTC+9 Kato Richardson:

Nicolas Garnier

unread,
Jul 7, 2016, 6:57:11 PM7/7/16
to Firebase Google Group
Hey Takuji,

We've made some progress and you can now have Firebase working in Chrome Extensions.
While we do not support signInWithPopup/Redirect in Chrome extensions/apps yet, you can work around it by using the chrome.identity API. You need to do the following:
 - Use the chrome.identity API to get a Google OAuth token as described in: https://developer.chrome.com/apps/app_identity
 - Enable Google as a Sign-In Provider in the Firebase Console
 - Add your Chrome App ID to the whitelist of the Client ID using the Developer's Console (There should be a Client ID that has been auto-generated by Firebase that's named "Web client (auto created by Google Service)")
 - Use the OAuth token to authorize Firebase using Auth.signInWithCredential. Basically the core of the auth code should look like:
chrome.identity.getAuthToken({}, function(token) {
var credential = firebase.auth.GoogleAuthProvider.credential(null, token);
firebase.auth().signInWithCredential(credential);
});
 - You can remove the `authDomain` attribute of the `config` Object in the Firebase SDK initialization code to avoid loading the auth iFrame (which would improve performance a bit and is only needed for signInWithPopup/Redirect).

While this is a bit more work and set up than using signInWithPopup this offers a nice 'native'-like experience as the chrome.identity API uses the account the chrome browser is signed-in with.

I'm working on a sample that I'll publish hopefully tomorrow.

Let me know if you have any questions.

Cheers!

Nicolas Garnier

unread,
Jul 8, 2016, 11:49:16 AM7/8/16
to Firebase Google Group

binoy balu

unread,
Jul 10, 2016, 10:41:51 AM7/10/16
to Firebase Google Group
Thanks for that!. I'd be good to get the signOut option so that we can remove both firebase user and also the token from chrome identity internals.
Reply all
Reply to author
Forward
0 new messages