Firebase-js-sdk: Firebase auth "auth/operation-not-supported-in-this-environment"

Created on 10 Mar 2018  路  14Comments  路  Source: firebase/firebase-js-sdk

[REQUIRED] Describe your environment

  • Operating System version: Windows 10
  • Firebase SDK version: ^4.11.0
  • Firebase Product: auth

[REQUIRED] Describe the problem

On the stencil environment, doing:

import firebase from 'firebase';

firebase.initializeApp({ ... config ... });
firebase.auth().signInWithPopup(new firebase.auth.GoogleAuthProvider());

causes:

code: "auth/operation-not-supported-in-this-environment"
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."

The environment is HTTP, on localhost, and Storage is defined.

Relevant Code:

See: https://github.com/AmitMY/firebase-stencil-issue
The last commit (firebase issue) is the code I added to the starter.

auth

Most helpful comment

image

All 14 comments

Please provide information about your environment. For Ionic mobile apps, you need to follow the documentation provided at: https://firebase.google.com/docs/auth/web/cordova

As mentioned, my environment is a stencil server, on Windows 10.

Chrome: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"

THIS IS NOT CORDOVA, nor is it really ionic. it is a new thing being released soon.

I see. Unfortunately, I have no knowledge of this new environment. If it does not support web storage (localStorage or indexedDB), is not an http/https environment or does not support DOM, then operations like signInWithPopup|Redirect will not work. This currently only works in a browser, chrome extension and Cordova/Ionic environment. What you can do instead is use an OAuth library that is supported by this environment to get an OAuth access token and then use APIs like
firebase.auth().signInWIthCredential(firebase.auth.FacebookAuthProvider.credential(fbAccessToken));
to complete sign-in to Firebase.
You can label this as a feature request to support this new environment.

I might have been unclear, let me rephrase.

  • The environment is an http-server serving static files from local disk, much similar to http-server
  • The app is opened in Google Chrome (an environment that does support all of the above), in http protocol, on http://localhost:3333

It shouldn't be too different than any HTTP server, and I would really appreciate if you just clone the repository and npm i && npm start to see what I mean.

image

I am getting this error, but I am testing something work. As it stands I literally just wrote a HTML file with JS. The var config and