12

uncaught exception: 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.

var config = {
apiKey: "*****",
authDomain: "******",
};
firebase.initializeApp(config);
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('https://www.googleapis.com/auth/drive');
firebase.auth().signInWithRedirect(provider);
alert(1);
}
ArunKarthick
  • 121
  • 1
  • 1
  • 6

3 Answers3

8

uncaught exception: 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.

Recently even i faced the same error.

You are opening this file directly in the browser without any web server. Firebase authentication won't work if you open the file directly. Try to load your HTML through web server it should solve your issue. The reason behind this bug is when you use authentication services they will use web storage. web storage does not work when you open an HTML file directly without any web browser

For example, use apache and open through apache like http://localhost/filename.html in the browser

Dinesh undefined
  • 5,490
  • 2
  • 19
  • 40
-1

Try this code. It should work.

    var config = {
    apiKey: "*****",
    authDomain: "******",
    };
    firebase.initializeApp(config);
    var provider = new firebase.auth.GoogleAuthProvider();
    provider.addScope('profile');
    provider.addScope('https://www.googleapis.com/auth/drive');
    firebase.auth().signInWithRedirect(provider);
    //add the code below to your previous lines
    firebase.auth().getRedirectResult().then(function(authData) {
        console.log(authData);
    }).catch(function(error) {
        console.log(error);
    });
Damien
  • 1,582
  • 1
  • 13
  • 24
-3

Most simple way.... just upload your files on github and run with github page(i.e. https://ur name.github.io/yr dir/yr html file.

  • This would rely on adding Github as an authorised domain for accessing your Firebase project. In turn, this would allow any Github-hosted page access to your project. – kdpnz Jan 26 '22 at 18:57