Giter Club home page Giter Club logo

Comments (9)

bojeil-google avatar bojeil-google commented on September 13, 2024 5

Electron is not currently officially supported by Firebase Auth. It is currently treated as a node.js server environment. In node.js server environment, only in memory persistence is supported.

from firebaseui-web-react.

 avatar commented on September 13, 2024 1

Thanks for replying.

I have a follow-up question.

In the code, I am not explicitly setting authentication state persistence mode.

By default, the persistence type should be set to firebase.auth.Auth.Persistence.NONE in the case of Electron ( as it is treated as a node.js server environment ).

I tried setting persistence to firebase.auth.Auth.Persistence.NONE using firebase.auth().setPersistence(firebase.auth.Auth.Persistence.NONE) but it did not seem to make any difference and error is still being shown.

My question-
Is there any way to set the appropriate persistence mode so that this error is not shown?

from firebaseui-web-react.

bojeil-google avatar bojeil-google commented on September 13, 2024 1

Hmm, not sure why this is happening. For now, you don't have to set it explicitly. The default and only available behavior should apply. Will try to look into this when I have time to setup an electronjs app.

from firebaseui-web-react.

bojeil-google avatar bojeil-google commented on September 13, 2024

Forgot to give an update on this. Electron is not officially supported (we haven't directly tested that environment). What is happening here is that the underlying firebase-auth SDK is mistaking Electron environment with a Node.js environment where only "In memory" persistence is supported.

from firebaseui-web-react.

max-mapper avatar max-mapper commented on September 13, 2024

I came up with a monkeypatch workaround for anyone else that hits this issue:

// HACK to trick firebase into allowing persistence in electron
if (typeof window !== 'undefined') {
  var orig = firebase.INTERNAL.node
  delete firebase.INTERNAL.node
  firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL)
  firebase.INTERNAL.node = orig
}

The browser detection in Firebase doesn't account for electron. It thinks electron is node, and therefore disables the LOCAL persistence option. Should be a really easy fix

from firebaseui-web-react.

locohost avatar locohost commented on September 13, 2024

@maxogden Thanks for posting this Max! However, it doesn't work for me. I'm building an Electron app that accesses Firestore. I'm setting up sign-in in a new window. In the auth.js page I put your above code right below the firebase.initializeApp(config); line. I'm getting same error above in console. Am I doing anything wrong or missing a step? Thank you!

Also, I'm trying to use FirebaseUI. Is this the problem? Can I not use that? Error occurs on the ui = new firebaseui.auth(... line...

	firebase.initializeApp(config);
	// HACK to trick firebase into allowing persistence in electron
	if (typeof window !== 'undefined') {
		debugger;
		const orig = firebase.INTERNAL.node;
		delete firebase.INTERNAL.node;
		firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL);
		firebase.INTERNAL.node = orig;
	}
	// Initialize the FirebaseUI Widget using Firebase.
	ui = new firebaseui.auth.AuthUI(firebase.auth());
	// The start method will wait until the DOM is loaded.
	ui.start('#firebaseui-auth-container', uiConfig);

from firebaseui-web-react.

max-mapper avatar max-mapper commented on September 13, 2024

@locohost Ahh sorry I haven't tested with firebaseui. I'm just using require('firebase'). I guess both firebaseui and firebase use the same Firebase Auth module, but I found this issue via google. You could try never doing firebase.INTERNAL.node = orig;, but I'm not sure if that will mess anything up.

from firebaseui-web-react.

locohost avatar locohost commented on September 13, 2024

Thank you @maxogden ! I got some other firebase.auth stuff working. Seems like a lot of firebase shi..stuff just doesn't want to work in Electron.

from firebaseui-web-react.

jhuleatt avatar jhuleatt commented on September 13, 2024

Check out this thorough blog post on using Firebase + Electron: https://medium.com/firebase-developers/using-firebase-in-electron-tips-and-tricks-24ac5b44bf5a

from firebaseui-web-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.