FR: Support moz-extension as well as chrome-extension.
[REQUIRED] Describe your environment
- Operating System version: Mac OS X 10.15
- Browser version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:82.0) Gecko/20100101 Firefox/82.0
- Firebase SDK version: 7.24.0
- Firebase Product: auth (auth, database, storage, etc)
Firefox extensions use the scheme moz-extension but Firebase auth only works with chrome-extension.
Maybe there needs to be a web-extension URI scheme?
Anyway. Firebase auth needs to support this as our chrome extension works fine but won't work in Firebase.
This should be a super simple fix and I can just submit a PR.
Steps to reproduce:
Relevant Code:
https://stackblitz.com/fork/firebase-issue-sandbox
// TODO(you): code here to reproduce the problem
Looking through this now the main issue is that a number of things assume chrome extension not extensions for other platforms/browsers.
For example:
/**
* @private @const {string} The Chrome extension invalid origin message
* template.
*/
fireauth.InvalidOriginError.CHROME_EXTENSION_MESSAGE_TEMPLATE_ = 'This chrom' +
'e extension ID (chrome-extension://%s) is not authorized to run this op' +
'eration. Add it to the OAuth redirect domains list in the Firebase cons' +
'ole -> Auth section -> Sign in method tab.';
... I'm not sure it makes sense to create a error for all of them so we might need to pass the extension scheme.
I have a branch here:
https://github.com/polar-app/firebase-js-sdk
but I think it will require a bit more work as there needs to be a generic method to work with extension types. I'm sure Safari and MS Edge have different extension schemes and those should be supported too.
Hey there! I've filed b/172259549 to track this feature request internally :)
Hello, are there any updates on if or when this will be addressed?
This is a big issue too as it's anti-competitive for Google to block other browsers (whether inadvertent or not).
Changing this SDK alone is not enough to allow moz-extension to work as the Authorized domains list in Firebase Console prevents the addition of moz-extension:// domains.
Anyone know of a workaround that allows auth to work in Firefox extensions?
For Google auth I ended up using browser.identity.launchWebAuthFlow (to https://accounts.google.com/o/oauth2/v2/auth with the client ID used by Firebase), parsing the id token in the result and calling the following:
const credential = firebase.auth.GoogleAuthProvider.credential(idToken);
const userCredentials = await firebase.auth().signInWithCredential(credential);
Hi! I'm on the Firebase team. This would be a welcomed community contribution. Feel free to open your PR as a work in progress if you'd like feedback.
Hi @rachelmyers, as mentioned earlier, even if the SDK were to allow moz-extension, it would not work as the following page in the Firebase console does not allow moz-extension:// to be input.

@nopol10 do you find a solution?
For Google auth I ended up using
browser.identity.launchWebAuthFlow(to https://accounts.google.com/o/oauth2/v2/auth with the client ID used by Firebase), parsing the id token in the result and calling the following:const credential = firebase.auth.GoogleAuthProvider.credential(idToken); const userCredentials = await firebase.auth().signInWithCredential(credential);
@Pierre-CLIND this was what I used to overcome the issue. A more complete implementation can be found here: https://github.com/nopol10/nekocap/blob/1c5dff15b11e7bc4bce206a42437e68b33150f6c/src/common/providers/parse/parse-provider.tsx#L80
@nopol10 I still get the auth/unauthorized-domain and auth/operation-not-supported-in-this-environment errors following the logic in your code. When I try to add the mozilla extension, I get the validation error you mentioned. Is there something I am missing?
For Google auth I ended up using
browser.identity.launchWebAuthFlow(to https://accounts.google.com/o/oauth2/v2/auth with the client ID used by Firebase), parsing the id token in the result and calling the following:const credential = firebase.auth.GoogleAuthProvider.credential(idToken); const userCredentials = await firebase.auth().signInWithCredential(credential);@Pierre-CLIND this was what I used to overcome the issue. A more complete implementation can be found here: https://github.com/nopol10/nekocap/blob/1c5dff15b11e7bc4bce206a42437e68b33150f6c/src/common/providers/parse/parse-provider.tsx#L80
Sorry for necro, but I think this can help anyone in the future who is developing a cross-platform browser extension for Chrome/Chromium and Firefox using Firebase as their auth provider and Firestore for their db.
nopol10's solution worked for me, but I had to apply the same solution for my Chrome login because otherwise my Firestore security rules WOULD NOT PICK UP that a user had been auth'ed in after they logged in. You can see more about why here, hopefully this helps anyone: https://github.com/p-o-f/ShareYT/commit/49619e0d2110636c1086717fc325b891dd5fff5a