Using Firebase with Electron

I don't know if this is the best solution but is a workaround.

create a file server.js with a simple express server

"server.js"

var express = require('express');
var http = require('http');
var path = require('path');

var appServer = express();
appServer.use(express.static(path.join(__dirname, '')));

appServer.get('*', (req, res) => {
    res.sendFile(__dirname + 'index.html');
});

http.createServer(appServer).listen(3007, function() {
    console.log('Express server listening on port');
});

In your main.js(electron-main-js-file)

On the top of the main.js start the node server

require('./server');

and change the "win.loadURL"

win.loadURL('http://localhost:3007');

I've fork your project and implement, the error from firebase is gone but jQuery is not defined, I think you can fix that.

https://github.com/diegoddox/sad-electron-firebase-error


You can use firebase auth's GitHub, Twitter, Facebook, Google Provider with electron by using the manual sign in flow and firebase auth signInWithCredential method.

https://firebase.google.com/docs/auth/web/github-auth#handle_the_sign-in_flow_manually

I created useful library for these case.

https://github.com/mironal/electron-oauth-helper#firebase-auth-integration

// Github manually flow example.

const { OAuth2Provider } = require("electron-oauth-helper")

const config = { /* oauth config. please see example/main/config.example.js.  */}
const provider = new OAuth2Provider(config)
provider.perform()
  .then(resp => {
    const query = querystring.parse(resp)
    const credential = firebase.auth.GithubAuthProvider.credential(query.access_token)
    firebase.auth().signInWithCredential(credential)
    .then(user => {
        console.log(user)
    })
    .catch(error => console.error(error))
  })
  .catch(error => console.error(error))

For now, you can suppress this error by removing the authDomain line from your config. authDomain is needed for the Auth signInWithPopup/signInWithRedirect operations, but everything else should work.

A version of the library that throws that error only when you actually try to do a signInWithPopup/Redirect is in the works.