mdmb
mdmb

Reputation: 5283

Electron: Firebase and Facebook authentication?

I'm trying to provide additional authentication for user within an app. With email/password auth already implemented, I wanted to add Facebook/ Google authentication as well.

I've tried with firebaseui:

const ui = new firebaseui.auth.AuthUI(firebase.auth());
ui.start(selector, {
  callbacks: {
    signInSuccessWithAuthResult(authResult) {
      that.handleAuthentication(authResult);
      return false;
    },
  },
  credentialHelper: firebaseui.auth.CredentialHelper.NONE,
  signInFlow: 'redirect',
  signInOptions: [
    {
      provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
    },
    {
      provider: firebase.auth.GoogleAuthProvider.PROVIDER_ID,
    },
    {
      provider: firebase.auth.FacebookAuthProvider.PROVIDER_ID,
    },
  ],
});

While the UI is rendered correctly in the passed selector, I cannot open Google/ Facebook authentication as it brings this message:

This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.

This is correct, since location.protocol is equal to file:.

My question is - how can I make it possible to use Facebook/ Google auth within an Electron app?

Upvotes: 5

Views: 591

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317427

Firebase Authentication for web isn't supported in this way for desktop applications. The web SDK is intended to work for browser clients, where the user can be redirected into a web page that performs the third party authentication. This isn't so easy for desktop javascript (Electron) apps that are not browsers. You are free to try to obtain an authentication token somehow on your own, but the client SDK isn't going to be able to help you with that.

Upvotes: 2

Related Questions