Firebase Web身份验证不起作用



我试图在我的网站中添加firebase身份验证。我尝试了此代码:

<!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>

但是,当我访问Localhost时,它只是显示"欢迎来到我的真棒应用程序",而没有验证提供商,也没有看到容器。请帮忙注意:您也可以在本地主机中测试此代码。

您在控制台中遇到以下错误: Uncaught ReferenceError: firebase is not defined

您不包括Firebase JS CDN: <script src="https://www.gstatic.com/firebasejs/4.8.1/firebase.js"></script>

相关内容

  • 没有找到相关文章

最新更新