question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

See original GitHub issue

Hi, I’m using cordova and followed firebase, firebaseUI tutorials like a bible. I successfully created the web part of the App which uses Google Auth / OAuth. I can also manipulate the User data from the browser.

The problem is when I build it via cordova build android and install it on my android phone; I get this error:

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. Dismiss

I could not find any solution from google, my hair is almost gone and Auth is a must in my app. Cordova is using File (file://) protocol if I’m not mistaken. And I think, God-forbid, firebase does not like that protocol using any Authentication method. I also found out that firebase SDK just had an update 15 hours ago that has Auth updates. I updated to that version (4.1.2 to 4.1.3) but still, no luck.

Facebook and Google Sign In works in a Computer Browser and there’s no problem.

Is anybody experiencing or have solved this? Please enlighten me.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bojeil-googlecommented, Jun 22, 2017

You need to isolate the issue. Can you first render FirebaseUI without angular? Most of the times the issue is from something else. Also if you are building from scratch (new Cordova app), add the FirebaseUI and firebase.initializeApp() code in the www/js/index.js after app.initialize(); Let me know if this helps.

1reaction
jcbagtascommented, Jun 22, 2017

Here is my setup:

var config = {
		apiKey: "somerandom-string",
		authDomain: "myapp.firebaseapp.com",
		databaseURL: "https://myapp.firebaseio.com",
		projectId: "myapp",
		storageBucket: "myapp.appspot.com",
		messagingSenderId: "1234567890"
	  };
firebase.initializeApp(config);
var uiConfig = {
	callbacks: {
		signInSuccess: function(user, credential, redirectUrl) {
			if(user){
				angular.element('.player-views #player-email').html(user.email);
				alert(user.email);
			}else{
				angular.element('.guest-views').show();
				angular.element('.player-views').hide();
				alert('NO USER');
			}
			$rootScope.user	= user;
			console.log($rootScope.user)
			return true;
		},
	},
	signInOptions: [
	  firebase.auth.GoogleAuthProvider.PROVIDER_ID,
	  firebase.auth.FacebookAuthProvider.PROVIDER_ID,
	],
	signInFlow: 'redirect'
}; 
var ui = new firebaseui.auth.AuthUI(firebase.auth());
ui.start('#firebaseui-auth-container', uiConfig);

I’m calling that on my Angular controller just right after it initiallizes. Firebase is initialized properly as my console.log there returns null and user data on the computer browser.

Also, in the android build window.cordova returns an object document.URL.indexOf(‘http://’) returns -1 document.URL.indexOf(‘https://’) returns -1 document.URL.indexOf(‘file://’) returns 0

I found this issue that is I think identical to mine, but he did not state how he actually fixed his problem. https://stackoverflow.com/questions/44651423/oauth-signin-cordova-firebase

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web Google authentication with firebase - Stack Overflow
... environment this application is running on. "location.protocol" must be HTTP, HTTPS or chrome-extension and web storage must be enabled.
Read more >
location.protocol must be http or https? - Google Groups
... operation is not supported in the environment this application is running on. "location.protocol" must be http or https and web storage must...
Read more >
User | JavaScript SDK | Node.js (client) API reference - Firebase
Reference for User.
Read more >
External HTTP(S) Load Balancing overview - Google Cloud
External HTTP(S) Load Balancing is a proxy-based Layer 7 load balancer that enables you to run and scale your services behind a single...
Read more >
Firebase auth/operation-not-supported-in-this-environment ...
... environment this application is running on. “location.protocol” must be http, https or chrome-extension and web storage must be enabled.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found