Web Google authentication with firebase

11,468

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

Share:
11,468

Related videos on Youtube

ArunKarthick
Author by

ArunKarthick

Updated on June 19, 2022

Comments

  • ArunKarthick
    ArunKarthick about 2 years

    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);
    }
    
    • jeffbyrnes
      jeffbyrnes about 7 years
      What’s your actual question here?
  • ArunKarthick
    ArunKarthick about 7 years
    thanks for ur reply. yeah that is true.i use that code in adobe cep extension it does not have any web browser. so is it possible to run that code without web server or web browser
  • ArunKarthick
    ArunKarthick about 7 years
    thank for ur reply. sorry that code not solved my problem
  • Dinesh undefined
    Dinesh undefined about 7 years
    sorry no idea.@ArunKarthick
  • ArunKarthick
    ArunKarthick about 7 years
    is it possible with nodejs
  • Dinesh undefined
    Dinesh undefined about 7 years
    yes its possible. just create expressjs server and add your file there
  • ArunKarthick
    ArunKarthick about 7 years
    I am new in node. can you pls give any example with express js.
  • Dinesh undefined
    Dinesh undefined about 7 years
  • ArunKarthick
    ArunKarthick about 7 years
    sorry i can't understand that. that code includes port so app.listen(port) also worked in localhost!
  • Dinesh undefined
    Dinesh undefined about 7 years
    did you create server with port. if so open it using localhost:port
  • ArunKarthick
    ArunKarthick about 7 years
    is it possible to create server without port. my project must run without localhost
  • Dinesh undefined
    Dinesh undefined about 7 years
    without port we cant create ant server. by default http runs on port 80. if you want to run without port means run nodejs on port 80 with root permission
  • Mahmoud Niypoo
    Mahmoud Niypoo over 5 years
    @Dineshundefined i have used it with the nodejs server and call route by browser and bu another server (angular) and always got this error !!
  • jolly
    jolly about 4 years
    This is not a solution. The problem still persists in iOS for Firebase auth by Google
  • kdpnz
    kdpnz over 2 years
    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.