【发布时间】:2018-06-06 01:27:08
【问题描述】:
我试图在我的网站中添加 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 时,它只显示“欢迎使用我的真棒应用程序”,没有身份验证提供程序,也没有看到容器。 请帮忙 注意:您也可以在 Localhost 中测试此代码。
【问题讨论】:
-
在teachinger.cu.ma/auth上传的代码
标签: html firebase firebase-authentication firebaseui