0

I was trying to add Firebase authentication in my website. I tried this code:

<!DOCTYPE html>
<html>
    <head>
    <meta charset="UTF-8"> 
    <title>
        Sample FirebaseUI App
    </title>
    <!-- ******************************************************************************************* * TODO(DEVELOPER): Paste the initialization snippet from: * Firebase Console > Overview > Add Firebase to your web app. * ***************************************************************************************** -->
    <script type="text/javascript">
        // Initialize Firebase
  var config = {
    apiKey: "AIzaSyB7cfgbxS4UgkGwsHyFgYwa6Ir7eRTWHM0",
    authDomain: "web-teachinger.firebaseapp.com",
    databaseURL: "https://web-teachinger.firebaseio.com",
    projectId: "web-teachinger",
    storageBucket: "",
    messagingSenderId: "1070392376591"
  };
  firebase.initializeApp(config);
    </script>
    <script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script>
    <link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.css" />
    <script type="text/javascript">
  firebase.initializeApp(config);
        // FirebaseUI config. 
        var uiConfig = { 
        signInSuccessUrl: 'success.html', signInOptions: [
        // Leave the lines as is for the providers you want to offer your users. 
firebase.auth.GoogleAuthProvider.PROVIDER_ID, 
firebase.auth.FacebookAuthProvider.PROVIDER_ID, 
firebase.auth.TwitterAuthProvider.PROVIDER_ID, 
firebase.auth.GithubAuthProvider.PROVIDER_ID, 
firebase.auth.EmailAuthProvider.PROVIDER_ID, 
firebase.auth.PhoneAuthProvider.PROVIDER_ID 
], 
// Terms of service url. 
tosUrl: 'TOS.php' }; 
// Initialize the FirebaseUI Widget using Firebase. 
var ui = new firebaseui.auth.AuthUI(firebase.auth()); 
// The start method will wait until the DOM is loaded. 
ui.start('#firebaseui-auth-container', uiConfig); 
   </script>
  </head> 
  <body>
     <!-- The surrounding HTML is left untouched by FirebaseUI. Your app may use that space for branding, controls and other customizations.-->
     <h1>
         Welcome to My Awesome App
     </h1>
  <div id="firebaseui-auth-container">
  </div>
 </body>
</html>

But when I visiting Localhost, it's just showing "Welcome to My Awesome App" and no auth providers and no container seen. Please help Note: You can also test this code in your Localhost.

user8984670
  • 21
  • 1
  • 2
  • 5

1 Answers1

0

You are getting the following error in the console: Uncaught ReferenceError: firebase is not defined

You are not including the Firebase JS CDN: <script src="https://www.gstatic.com/firebasejs/4.8.1/firebase.js"></script>

bojeil
  • 29,642
  • 4
  • 69
  • 76