Comments (9)
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.
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.
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.
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.
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.
@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.
@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.
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.
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)
- One tap login not working HOT 7
- /example/README.md doesn't mention creating an app first HOT 2
- Firebase-config.json is not created! HOT 1
- Support React 18 HOT 6
- Error when using PhoneAuthProvider - Uncaught TypeError: app.auth is not a function HOT 8
- React 18 StrictMode causes "AuthUI instance is deleted" error HOT 4
- StyledFirebaseAuth does not render with firebase ^9.8.1 HOT 3
- Question: how to get a refresh token
- Cannot Install in React 18.2 HOT 5
- Styledfirebaseui don't know my initializaion HOT 2
- StyledFirebaseAuth not working with nextjs HOT 8
- `StyledFirebaseAuth` cannot be used as a JSX component HOT 1
- AnonymousAuthProvider signInOptions does not work; Throw a TypeError.
- React strict mode compatibility HOT 1
- [email protected] is not compatible with [email protected] HOT 11
- Is this project maintained? HOT 7
- Is there a builtin rate-limiter or CAPTCHA in this?
- How do I add a custom domain redirect to this auth? HOT 1
- Link with Multiple Accounts is not working
- Third-party cookie will be blocked in future Chrome versions as part of Privacy Sandbox.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebaseui-web-react.